Exemplo n.º 1
0
        public FEnum(FClass host, FieldWrap define, ImportExcel excel) : base(host, define)
        {
            EnumWrap info = EnumWrap.Enums[define.OriginalType];
            string   name = excel.GetEnum();

            EnumName = info.GetEnumName(name);
            EnumName = EnumName.IsEmpty() ? name : EnumName;
            Value    = info.GetEnumValue(EnumName);

            if (!info.ContainItem(name))
            {
                excel.Error($"未定义枚举(名称/别名){define.FullName}.{name}   !");
            }
        }
Exemplo n.º 2
0
        public static Data Create(FClass host, FieldWrap define, ImportExcel excel)
        {
            string type = define.OriginalType;

            if (define.IsRaw)
            {
                switch (type)
                {
                case Setting.BOOL:
                    return(new FBool(host, define, excel));

                case Setting.INT:
                    return(new FInt(host, define, excel));

                case Setting.LONG:
                    return(new FLong(host, define, excel));

                case Setting.FLOAT:
                    return(new FFloat(host, define, excel));

                case Setting.STRING:
                    return(new FString(host, define, excel));
                }
            }
            else if (define.IsEnum)
            {
                return(new FEnum(host, define, excel));
            }
            else if (define.IsClass)
            {
                if (!define.IsDynamic)
                {
                    return(new FClass(host, define, excel));
                }

                string    dType = excel.GetString();
                ClassWrap cls   = ClassWrap.Get(define.FullName);
                dType = ClassWrap.CorrectType(cls, dType);
                ClassWrap dynamic = ClassWrap.Get(dType);
                if (dynamic == null)
                {
                    excel.Error("多态类型" + dType + "未知");
                }
                if (cls.FullName != dType && !cls.HasChild(dType))
                {
                    excel.Error(string.Format("数据类型{0}非{1}子类", dType, cls.FullName));
                }
                var define0 = new FieldWrap(define.Host, define.Name, dType, new string[] { define.FullName }, define.Group);
                return(new FClass(host, define0, excel));
            }
            else if (define.IsContainer)
            {
                if (define.OriginalType == "list")
                {
                    return(new FList(host, define, excel));
                }
                else if (define.OriginalType == "dict")
                {
                    return(new FDict(host, define, excel));
                }
            }

            Util.LogError("未知类型" + type);
            return(null);
        }