GetSuggestedFieldType() static private method

static private GetSuggestedFieldType ( Type handlerSlotType ) : Type
handlerSlotType System.Type
return System.Type
Example #1
0
        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);

                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);
        }
Example #2
0
        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);
        }
Example #3
0
 public static Type GetSuggestedFieldType(Type propertyType)
 {
     return(FieldManager.GetSuggestedFieldType(propertyType));
 }