public static IDictionary <string, FieldMetadata> GetFieldMetadata(Type type, Func <FieldMetadata, bool> isHiddenCallback) { var data = new Dictionary <string, FieldMetadata>(); foreach (var propertyInfo in type.GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Public)) { if (!propertyInfo.CanRead) { continue; } var fieldType = FieldManager.GetSuggestedFieldType(propertyInfo.PropertyType); //if (fieldType == null) // throw new NotSupportedException(String.Concat("Cannot match any FieldType to the '", // propertyInfo.Name, "' property. Property type is: ", propertyInfo.PropertyType)); var fieldMeta = new FieldMetadata { PropertyInfo = propertyInfo, FieldName = propertyInfo.Name, PropertyType = propertyInfo.PropertyType, FieldType = fieldType, CanRead = propertyInfo.CanRead, CanWrite = propertyInfo.CanWrite }; if (fieldType != null && (isHiddenCallback == null || isHiddenCallback(fieldMeta))) { data.Add(propertyInfo.Name, fieldMeta); } } return(data); }
public static Type GetSuggestedFieldType(Type propertyType) { return(FieldManager.GetSuggestedFieldType(propertyType)); }