예제 #1
0
        private myPropInfo CreateMyProp(Type t, string name, bool customType)
        {
            myPropInfo     d      = new myPropInfo();
            myPropInfoType d_type = myPropInfoType.Unknown;

            if (t == typeof(int) || t == typeof(int?))
            {
                d_type = myPropInfoType.Int;
            }
            else if (t == typeof(long) || t == typeof(long?))
            {
                d_type = myPropInfoType.Long;
            }
            else if (t == typeof(string))
            {
                d_type = myPropInfoType.String;
            }
            else if (t == typeof(bool) || t == typeof(bool?))
            {
                d_type = myPropInfoType.Bool;
            }
            else if (t == typeof(DateTime) || t == typeof(DateTime?))
            {
                d_type = myPropInfoType.DateTime;
            }
            else if (t.IsEnum)
            {
                d_type = myPropInfoType.Enum;
            }
            else if (t == typeof(Guid) || t == typeof(Guid?))
            {
                d_type = myPropInfoType.Guid;
            }
            else if (t == typeof(StringDictionary))
            {
                d_type = myPropInfoType.StringDictionary;
            }
            else if (t == typeof(NameValueCollection))
            {
                d_type = myPropInfoType.NameValue;
            }
            else if (t.IsArray)
            {
                d.bt = t.GetElementType();
                if (t == typeof(byte[]))
                {
                    d_type = myPropInfoType.ByteArray;
                }
                else
                {
                    d_type = myPropInfoType.Array;
                }
            }
            else if (t.Name.Contains("Dictionary"))
            {
                d.GenericTypes = Reflection.Instance.GetGenericArguments(t);// t.GetGenericArguments();
                if (d.GenericTypes.Length > 0 && d.GenericTypes[0] == typeof(string))
                {
                    d_type = myPropInfoType.StringKeyDictionary;
                }
                else
                {
                    d_type = myPropInfoType.Dictionary;
                }
            }
#if !SILVERLIGHT
            else if (t == typeof(Hashtable))
            {
                d_type = myPropInfoType.Hashtable;
            }
            else if (t == typeof(DataSet))
            {
                d_type = myPropInfoType.DataSet;
            }
            else if (t == typeof(DataTable))
            {
                d_type = myPropInfoType.DataTable;
            }
#endif
            else if (customType)
            {
                d_type = myPropInfoType.Custom;
            }

            if (t.IsValueType && !t.IsPrimitive && !t.IsEnum && t != typeof(decimal))
            {
                d.IsStruct = true;
            }

            d.IsClass     = t.IsClass;
            d.IsValueType = t.IsValueType;
            if (t.IsGenericType)
            {
                d.IsGenericType = true;
                d.bt            = t.GetGenericArguments()[0];
            }

            d.pt         = t;
            d.Name       = name;
            d.changeType = GetChangeType(t);
            d.Type       = d_type;

            return(d);
        }