diff options
author | Eric Maupin <me@ermau.com> | 2017-07-03 21:53:16 +0300 |
---|---|---|
committer | Eric Maupin <me@ermau.com> | 2017-07-03 21:53:16 +0300 |
commit | c60e2083a51c218dd368490a7813b93e6e9c5543 (patch) | |
tree | 442e24443bfbf0b75ded5bb91bdc6e853d3ef42d /Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs | |
parent | 18715490f878172c1bf6d4c9bba4a7113098c187 (diff) |
[Mac] Allow unconstructed generics as vm/editor types
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs index 3a9cf70..79f07c7 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs @@ -66,18 +66,25 @@ namespace Xamarin.PropertyEditing.Mac var editor = (PropertyEditorControl)outlineView.MakeView (cellIdentifier + "edits", this); if (editor == null) { + Type[] genericArgs = null; Type controlType; Type propertyType = vm.GetType (); - if (viewModelTypes.TryGetValue (propertyType, out controlType)) { - editor = SetUpEditor (controlType, vm, outlineView); - } else { - if (propertyType.IsGenericType) { - Type genericType = propertyType.GetGenericTypeDefinition (); - if (genericType == typeof (EnumPropertyViewModel<>)) - controlType = typeof (EnumEditorControl<>).MakeGenericType (vm.Property.Type); - editor = SetUpEditor (controlType, vm, outlineView); + if (!ViewModelTypes.TryGetValue (propertyType, out controlType)) { + if (propertyType.IsConstructedGenericType) { + genericArgs = propertyType.GetGenericArguments (); + propertyType = propertyType.GetGenericTypeDefinition (); + ViewModelTypes.TryGetValue (propertyType, out controlType); } } + + if (controlType == null) + return null; + + if (controlType.IsGenericTypeDefinition) { + controlType = controlType.MakeGenericType (genericArgs); + } + + editor = SetUpEditor (controlType, vm, outlineView); } // we must reset these every time, as the view may have been reused |