Beispiel #1
0
        public FClass(FClass host, FieldWrap define, XmlElement value) : base(host, define)
        {
            _fullType = define.FullName;

            ClassWrap info = ClassWrap.Get(define.FullName);

            Load(info, value);
        }
Beispiel #2
0
        public FInt(FClass host, FieldWrap define, XmlElement value) : base(host, define)
        {
            string v = value.InnerText;
            int    r;

            if (!int.TryParse(v, out r))
            {
                Util.Error("{0}非int类型或者数值溢出", v);
                Value = -1;
            }
            Value = r;
        }
Beispiel #3
0
        public FLong(FClass host, FieldWrap define, XmlElement xml) : base(host, define)
        {
            string v = xml.InnerText;
            long   r;

            if (!long.TryParse(v, out r))
            {
                Util.Error("{0}非long类型或者数值溢出", v);
                Value = -1;
            }
            Value = r;
        }
Beispiel #4
0
        public FFloat(FClass host, FieldWrap define, XmlElement xml) : base(host, define)
        {
            string v = xml.InnerText;
            float  r;

            if (!float.TryParse(v, out r))
            {
                Util.Error("{0}非float类型或者数值溢出", v);
                Value = -1;
            }
            Value = r;
        }
Beispiel #5
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}   !");
            }
        }
Beispiel #6
0
        public FBool(FClass host, FieldWrap define, XmlElement xml) : base(host, define)
        {
            string v = xml.InnerText;

            if (v.Equals("true", StringComparison.CurrentCultureIgnoreCase))
            {
                Value = true;
            }
            else if (v.Equals("false", StringComparison.CurrentCultureIgnoreCase))
            {
                Value = false;
            }
            else
            {
                Util.Error("{0}非bool类型", v);
                Value = false;
            }
        }
Beispiel #7
0
        public FDict(FClass host, FieldWrap define, XmlElement data) : base(host, define)
        {
            _key   = define.GetKeyDefine();
            _value = define.GetValueDefine();

            XmlNodeList dict = data.ChildNodes;

            for (int i = 0; i < dict.Count; i++)
            {
                XmlNode    pair  = dict[i];
                XmlElement key   = pair[Setting.KEY];
                XmlElement value = pair[Setting.VALUE];
                var        dk    = Data.Create(host, _key, key);
                var        dv    = Data.Create(host, _value, value);
                if (!Values.ContainsKey(dk))
                {
                    Values.Add(dk, dv);
                }
                else
                {
                    Util.Error("字段:{0} Key:{1} 重复", define.Name, dk);
                }
            }
        }
Beispiel #8
0
 public FClass(FClass host, FieldWrap define, ImportExcel excel) : base(host, define)
 {
     _fullType = define.FullName;
     excel.GetClass(this, ClassWrap.Get(define.FullName));
 }
Beispiel #9
0
 public FEnum(FClass host, FieldWrap define, XmlElement xml) : base(host, define)
 {
     Value = xml.InnerText;//Xml中枚举以int表示
 }
Beispiel #10
0
 public FLong(FClass host, FieldWrap define, ImportExcel excel) : base(host, define)
 {
     Value = excel.GetLong();
 }
Beispiel #11
0
 public FDict(FClass host, FieldWrap define, ImportExcel excel) : base(host, define)
 {
     _key   = define.GetKeyDefine();
     _value = define.GetValueDefine();
     excel.GetDict(this, define);
 }
Beispiel #12
0
 public FString(FClass host, FieldWrap define, XmlElement value) : base(host, define)
 {
     Value = value.InnerText;
 }
Beispiel #13
0
 public FList(FClass host, FieldWrap define, ImportExcel excel) : this(host, define)
 {
     excel.GetList(this, define);
 }
Beispiel #14
0
 public FList(FClass host, FieldWrap define) : base(host, define)
 {
     _item = define.GetItemDefine();
 }
Beispiel #15
0
 public Data(FClass host, FieldWrap define)
 {
     _define = define;
     _host   = host;
 }
Beispiel #16
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);
        }
Beispiel #17
0
 public FFloat(FClass host, FieldWrap define, ImportExcel excel) : base(host, define)
 {
     Value = excel.GetFloat();
 }