(object data)
| 35 | public class ViewLocator : IDataTemplate |
| 36 | { |
| 37 | public Control Build(object data) |
| 38 | { |
| 39 | var name = data.GetType().FullName?.Replace("ViewModel", "View"); |
| 40 | if (name is null) |
| 41 | { |
| 42 | return new TextBlock { Text = "Invalid Data Type" }; |
| 43 | } |
| 44 | var type = Type.GetType(name); |
| 45 | if (type is { }) |
| 46 | { |
| 47 | var instance = Activator.CreateInstance(type); |
| 48 | if (instance is { }) |
| 49 | { |
| 50 | return (Control)instance; |
| 51 | } |
| 52 | else |
| 53 | { |
| 54 | return new TextBlock { Text = "Create Instance Failed: " + type.FullName }; |
| 55 | } |
| 56 | } |
| 57 | else |
| 58 | { |
| 59 | return new TextBlock { Text = "Not Found: " + name }; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | public bool Match(object data) |
| 64 | { |
nothing calls this directly
no test coverage detected