private static EnumDataDefine CreateType(Type type, EnumFieldType fieldType) { Type rawType = null; bool isNullable = false; if (type.IsGenericType) { Type frameType = type.GetGenericTypeDefinition(); if (frameType.FullName == "System.Nullable`1") { Type[] arguments = type.GetGenericArguments(); rawType = arguments [0]; isNullable = true; } } if (rawType == null) { rawType = type; } if (!rawType.IsEnum) { throw new LightDataException(RE.SingleFieldSelectTypeError); } EnumDataDefine mapping = null; mapping = new EnumDataDefine(type, rawType, fieldType); mapping.IsNullable = isNullable; return(mapping); }
public static EnumDataDefine Create(Type type, EnumFieldType fieldType, string fieldName) { EnumDataDefine mapping = CreateType(type, fieldType); mapping.FieldName = fieldName; return(mapping); }
public static EnumDataDefine Create(Type type, EnumFieldType fieldType, int fieldOrder) { EnumDataDefine mapping = CreateType(type, fieldType); mapping.FieldOrder = fieldOrder; return(mapping); }