Exemplo n.º 1
0
        public ClassWrap(ClassXml des, string namespace0)
        {
            _des      = des;
            _fields   = new List <FieldWrap>();
            _children = new HashSet <string>();
            if (Name.IsEmpty())
            {
                Error("未指定Class名称");
            }
            if (!Util.MatchIdentifier(Name))
            {
                Error("命名不合法:" + Name);
            }

            _namespace = namespace0;
            _fullName  = string.Format("{0}.{1}", namespace0, des.Name);
            _inherit   = des.Inherit;
            _inherit   = CorrectType(this, _inherit);
            _groups    = new HashSet <string>(Util.Split(des.Group == null ? "" : des.Group.ToLower()));
            if (_groups.Count == 0)
            {
                _groups.Add(Setting.DefualtGroup);
            }

            Add(this);
            _fields = new List <FieldWrap>();
            for (int i = 0; i < des.Fields.Count; i++)
            {
                var fieldDes = des.Fields[i];
                var info     = new FieldWrap(this, fieldDes.Name, fieldDes.Type, fieldDes.Group, fieldDes.Desc, fieldDes.Attribute, _groups);
                info.CreateChecker(fieldDes);
                Fields.Add(info);
            }
            _consts = new List <ConstWrap>();
            for (int i = 0; i < des.Consts.Count; i++)
            {
                var constDes = des.Consts[i];
                var info     = new ConstWrap(this, constDes.Name, constDes.Type, constDes.Value, constDes.Group, constDes.Desc, _groups);
                Consts.Add(info);
            }
        }