Beispiel #1
0
        protected Int16 GetFieldType(Type tar, int c)
        {
            if (c == 1)
            {
                ChildTypeName = tar.Name;
                type1         = tar;
            }
            else if (c == 2)
            {
                ChildTypeName2 = tar.Name;
            }
            c++;
            if (tar.IsArray)
            {
                var   son = tar.GetElementType();
                Int16 typ = GetFieldType(son, c);
#if ENABLE_MONO
                if (dataInfo.CreateConstruction)
                {
                    int a = typ;
                    if (a < 32)
                    {
                        if (typ == DataType2.Struct | typ == DataType2.Class)//[]
                        {
                            ArrayConstruction = DataInfo.GetCreateFuncArray(son);
                        }
                    }
                    else
                    {
                        ArrayConstruction2 = DataInfo.GetCreateFuncArray(son);
                    }
                }
#endif
                return((Int16)(typ + 32));
            }
            else if (tar.IsClass)
            {
                if (tar.Name == "String")
                {
                    return(DataType2.String);
                }
                else if (tar.IsGenericType)//泛型类
                {
                    if (tar.Name == DataType2.List)
                    {
                        DBType = DataType2.Int16Array;
                        var   tps = tar.GetGenericArguments();
                        var   son = tps[0];
                        Int16 typ = GetFieldType(son, c);
#if ENABLE_MONO
                        if (dataInfo.CreateConstruction)
                        {
                            if (typ == DataType2.Struct | typ == DataType2.Class)//List<T[]>
                            {
                                Construction = DataInfo.GetCreateFunc(tar);
                            }
                            else if (typ > 31)
                            {
                                Construction2 = DataInfo.GetCreateFunc(tar);
                            }
                        }
#endif
                        return((Int16)(typ + 32));
                    }
                }
                typeInfo          = dataInfo.Analysis(tar);
                HaveTable         = true;
                ChildTypeFullName = typeInfo.fullName;
                return(DataType2.Class);
            }
            else if (tar.IsEnum)
            {
                return(DataType2.Int32);
            }
            else if (tar.IsValueType)
            {
                switch (tar.Name)
                {
                case "Byte":
                case "SByte":
                    return(DataType2.Byte);

                case "Boolean":
                    return(DataType2.Boolean);

                case "Int16":
                case "UInt16":
                case "Char":
                    return(DataType2.Int16);

                case "Int32":
                case "UInt32":
                    return(DataType2.Int32);

                case "Single":
                    return(DataType2.Float);

                case "Int64":
                case "UInt64":
                    return(DataType2.Int64);

                case "Double":
                    return(DataType2.Double);

                case "Decimal":
                    return(DataType2.Decimal);

                default:    //这是一个结构体
                    typeInfo          = dataInfo.Analysis(tar);
                    ElementLength     = typeInfo.ElementLength;
                    DataLength        = (Int16)typeInfo.DataLength;
                    HaveTable         = true;
                    ChildTypeFullName = typeInfo.fullName;
                    return(DataType2.Struct);
                }
            }
            return(DataType2.Int32);
        }