PropertyEditorControl GetEditor(EditorViewModel vm, NSOutlineView outlineView) { Type[] genericArgs = null; Type controlType; Type propertyType = vm.GetType(); 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) { if (genericArgs == null) { genericArgs = propertyType.GetGenericArguments(); } controlType = controlType.MakeGenericType(genericArgs); } return(SetUpEditor(controlType, vm, outlineView)); }
public virtual IEditorView GetEditor(IHostResourceProvider hostResources, EditorViewModel vm) { if (hostResources == null) { throw new ArgumentNullException(nameof(hostResources)); } Type[] genericArgs = null; Type controlType; Type propertyType = vm.GetType(); 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) { if (genericArgs == null) { genericArgs = propertyType.GetGenericArguments(); } controlType = controlType.MakeGenericType(genericArgs); } return((IEditorView)Activator.CreateInstance(controlType, hostResources)); }