Inheritance: System.Attribute
Esempio n. 1
0
        private DBField(PropertyInfo propertyInfo, DBFieldAttribute attribute)
        {
            this.propertyInfo = propertyInfo;
            this.attribute = attribute;

            // determine how this shoudl be stored in the DB
            type = DBDataType.TEXT;

            if (propertyInfo.PropertyType == typeof(string))
                type = DBDataType.TEXT;
            else if (propertyInfo.PropertyType == typeof(int))
                type = DBDataType.INTEGER;
            else if (propertyInfo.PropertyType == typeof(int?))
                type = DBDataType.INTEGER;
            else if (propertyInfo.PropertyType == typeof(long))
                type = DBDataType.LONG;
            else if (propertyInfo.PropertyType == typeof(long?))
                type = DBDataType.LONG;
            else if (propertyInfo.PropertyType == typeof(float))
                type = DBDataType.REAL;
            else if (propertyInfo.PropertyType == typeof(float?))
                type = DBDataType.REAL;
            else if (propertyInfo.PropertyType == typeof(double))
                type = DBDataType.REAL;
            else if (propertyInfo.PropertyType == typeof(double?))
                type = DBDataType.REAL;
            else if (propertyInfo.PropertyType == typeof(bool))
                type = DBDataType.BOOL;
            else if (propertyInfo.PropertyType == typeof(bool?))
                type = DBDataType.BOOL;
            else if (propertyInfo.PropertyType == typeof(Boolean))
                type = DBDataType.BOOL;
            else if (propertyInfo.PropertyType == typeof(DateTime))
                type = DBDataType.DATE_TIME;
            else if (propertyInfo.PropertyType == typeof(DateTime?))
                type = DBDataType.DATE_TIME;
            else if (propertyInfo.PropertyType == typeof(Type))
                type = DBDataType.TYPE;
            else if (propertyInfo.PropertyType.IsEnum)
                type = DBDataType.ENUM;
            // nullable enum
            else if (Nullable.GetUnderlyingType(propertyInfo.PropertyType) != null ? Nullable.GetUnderlyingType(propertyInfo.PropertyType).IsEnum : false)
                type = DBDataType.ENUM;
            else if (DatabaseManager.IsDatabaseTableType(propertyInfo.PropertyType))
                type = DBDataType.DB_OBJECT;
            else if (propertyInfo.PropertyType == typeof(DBField))
                type = DBDataType.DB_FIELD;
            else if (propertyInfo.PropertyType == typeof(DBRelation))
                type = DBDataType.DB_RELATION;
            else {
                // check for string object types
                foreach (Type currInterface in propertyInfo.PropertyType.GetInterfaces())
                    if (currInterface == typeof(IStringSourcedObject)) {
                        type = DBDataType.STRING_OBJECT;
                        return;
                    }
            }
        }
Esempio n. 2
0
        private DBField(PropertyInfo propertyInfo, DBFieldAttribute attribute)
        {
            this.propertyInfo = propertyInfo;
            this.attribute    = attribute;

            // determine how this shoudl be stored in the DB
            type = DBDataType.TEXT;

            if (propertyInfo.PropertyType == typeof(string))
            {
                type = DBDataType.TEXT;
            }
            else if (propertyInfo.PropertyType == typeof(int))
            {
                type = DBDataType.INTEGER;
            }
            else if (propertyInfo.PropertyType == typeof(int?))
            {
                type = DBDataType.INTEGER;
            }
            else if (propertyInfo.PropertyType == typeof(long))
            {
                type = DBDataType.LONG;
            }
            else if (propertyInfo.PropertyType == typeof(long?))
            {
                type = DBDataType.LONG;
            }
            else if (propertyInfo.PropertyType == typeof(float))
            {
                type = DBDataType.REAL;
            }
            else if (propertyInfo.PropertyType == typeof(float?))
            {
                type = DBDataType.REAL;
            }
            else if (propertyInfo.PropertyType == typeof(double))
            {
                type = DBDataType.REAL;
            }
            else if (propertyInfo.PropertyType == typeof(double?))
            {
                type = DBDataType.REAL;
            }
            else if (propertyInfo.PropertyType == typeof(bool))
            {
                type = DBDataType.BOOL;
            }
            else if (propertyInfo.PropertyType == typeof(bool?))
            {
                type = DBDataType.BOOL;
            }
            else if (propertyInfo.PropertyType == typeof(Boolean))
            {
                type = DBDataType.BOOL;
            }
            else if (propertyInfo.PropertyType == typeof(DateTime))
            {
                type = DBDataType.DATE_TIME;
            }
            else if (propertyInfo.PropertyType == typeof(DateTime?))
            {
                type = DBDataType.DATE_TIME;
            }
            else if (propertyInfo.PropertyType == typeof(Type))
            {
                type = DBDataType.TYPE;
            }
            else if (propertyInfo.PropertyType.IsEnum)
            {
                type = DBDataType.ENUM;
            }
            // nullable enum
            else if (Nullable.GetUnderlyingType(propertyInfo.PropertyType) != null ? Nullable.GetUnderlyingType(propertyInfo.PropertyType).IsEnum : false)
            {
                type = DBDataType.ENUM;
            }
            else if (DatabaseManager.IsDatabaseTableType(propertyInfo.PropertyType))
            {
                type = DBDataType.DB_OBJECT;
            }
            else if (propertyInfo.PropertyType == typeof(DBField))
            {
                type = DBDataType.DB_FIELD;
            }
            else if (propertyInfo.PropertyType == typeof(DBRelation))
            {
                type = DBDataType.DB_RELATION;
            }
            else
            {
                // check for string object types
                foreach (Type currInterface in propertyInfo.PropertyType.GetInterfaces())
                {
                    if (currInterface == typeof(IStringSourcedObject))
                    {
                        type = DBDataType.STRING_OBJECT;
                        return;
                    }
                }
            }
        }