public ListPropertyInfoDescriptor(PropertyInfo propertyInfo, PropertyDescriptorProvider provider) : base(provider) { PropertyInfo = propertyInfo; IsReadOnly = propertyInfo.CanWrite == false; Name = PropertyInfoDescriptor.GetName(propertyInfo, provider); DisplayName = PropertyInfoDescriptor.GetDescription(propertyInfo, provider); Category = PropertyInfoDescriptor.GetCategory(propertyInfo, provider); Description = PropertyInfoDescriptor.GetDescription(propertyInfo, provider); ItemPropertyDescriptor = new ListItemPropertyDescriptor <TCollection, TItem>(provider); _getter = PropertyInfoDescriptor.CreatePropertyGetter <TTarget, TCollection>(propertyInfo); _setter = propertyInfo.CanWrite ? PropertyInfoDescriptor.CreatePropertySetter <TTarget, TCollection>(propertyInfo) : null; }
private protected PropertyDescriptor(PropertyDescriptorProvider provider) { Provider = provider; }
protected CollectionPropertyDescriptor(PropertyDescriptorProvider provider) : base(provider) { }
internal CollectionItemPropertyDescriptor(PropertyDescriptorProvider provider) : base(provider) { }
internal ListItemPropertyDescriptor(PropertyDescriptorProvider provider) : base(provider) { }
public static string GetDescription(PropertyInfo propertyInfo, PropertyDescriptorProvider provider) { return(propertyInfo.Name); }
public static string GetCategory(PropertyInfo propertyInfo, PropertyDescriptorProvider provider) { return(null); }
public static PropertyDescriptor CreateDescriptor(Type propertyObjectType, PropertyInfo propertyInfo, PropertyDescriptorProvider provider) { var propertyType = propertyInfo.PropertyType; var genericListType = propertyType.GetInterfaces().FirstOrDefault(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IList <>)); if (genericListType != null) { var itemType = genericListType.GetGenericArguments().Single(); var collectionPropertyDescriptorType = typeof(ListPropertyInfoDescriptor <, ,>).MakeGenericType(propertyObjectType, propertyType, itemType); return((PropertyDescriptor)Activator.CreateInstance(collectionPropertyDescriptorType, propertyInfo, provider)); } var genericCollectionType = propertyType.GetInterfaces().FirstOrDefault(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(ICollection <>)); if (genericCollectionType != null) { var itemType = genericCollectionType.GetGenericArguments().Single(); var collectionPropertyDescriptorType = typeof(CollectionPropertyInfoDescriptor <, ,>).MakeGenericType(propertyObjectType, propertyType, itemType); return((PropertyDescriptor)Activator.CreateInstance(collectionPropertyDescriptorType, propertyInfo, provider)); } var propertyDescriptorType = typeof(PropertyInfoDescriptor <,>).MakeGenericType(propertyObjectType, propertyType); return((PropertyDescriptor)Activator.CreateInstance(propertyDescriptorType, propertyInfo, provider)); }