Beispiel #1
0
        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);
        }
Beispiel #2
0
        public static EnumDataDefine Create(Type type, EnumFieldType fieldType, string fieldName)
        {
            EnumDataDefine mapping = CreateType(type, fieldType);

            mapping.FieldName = fieldName;
            return(mapping);
        }
Beispiel #3
0
        public static EnumDataDefine Create(Type type, EnumFieldType fieldType, int fieldOrder)
        {
            EnumDataDefine mapping = CreateType(type, fieldType);

            mapping.FieldOrder = fieldOrder;
            return(mapping);
        }