Ejemplo n.º 1
0
        /// <summary>
        /// config作为字段定义
        /// </summary>
        public FieldWrap(ClassWrap host, string name, string fullName, string[] types, HashSet <string> gs)
        {
            _host     = host;
            _name     = name;
            _fullName = fullName;
            _types    = types;
            _groups   = gs;

            if (IsRaw || _host == null)
            {
                return;
            }
            if (IsContainer)
            {
                if (OriginalType == Setting.LIST && _types[1].IndexOfAny(Setting.DotSplit) < 0 &&
                    !Setting.RawTypes.Contains(_types[1]))
                {
                    _types[1] = string.Format("{0}.{1}", _host.Namespace, _types[1]);
                }
                else if (OriginalType == Setting.DICT && _types[2].IndexOfAny(Setting.DotSplit) < 0 &&
                         !Setting.RawTypes.Contains(_types[2]))
                {
                    _types[2] = string.Format("{0}.{1}", _host.Namespace, _types[2]);
                }
                _fullName = Util.ToString(_types, ":");
            }
            else if (_fullName.IndexOfAny(Setting.DotSplit) < 0)
            {
                _fullName = string.Format("{0}.{1}", _host.Namespace, _fullName);
                _types[0] = _fullName;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 当前类有子类
 /// </summary>
 public static bool IsDynamic(string fullName)
 {
     if (IsClass(fullName))
     {
         ClassWrap cls = _classes[fullName];
         return(cls != null && cls.IsDynamic());
     }
     return(false);
 }
Ejemplo n.º 3
0
 static void Add(ClassWrap info)
 {
     if (_classes.ContainsKey(info._fullName))
     {
         Util.LogWarningFormat("{1} 重复定义!", info._fullName);
     }
     else
     {
         _classes.Add(info._fullName, info);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 仅做局部修正矫正,不包含Module模块名
        /// </summary>
        public static string CorrectType(ClassWrap host, string type)
        {
            if (host == null)
            {
                return(type);
            }

            if (!type.IsEmpty() && type.IndexOfAny(Setting.DotSplit) < 0)
            {
                type = string.Format("{0}.{1}", host.Namespace, type);
            }
            return(type);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Class 字段
 /// </summary>
 public FieldWrap(ClassWrap host, string name, string fullName, string group, string desc, string attribute, HashSet <string> parentGroups)
     : this(host, name, fullName, Util.Split(fullName), parentGroups)
 {
     _group = group == null ? "" : group.ToLower();
     if (_groups == null)
     {
         _groups = new HashSet <string>(Util.Split(_group));
         if (_groups.Count == 0)
         {
             _groups.Add(Setting.DefualtGroup);
         }
     }
     _desc      = desc;
     _attribute = attribute;
 }
Ejemplo n.º 6
0
        public ConfigWrap(ClassXml des, string namespace0, string moduleDir)
        {
            _des       = des;
            _namespace = namespace0;
            _fullName  = string.Format("{0}.{1}", namespace0, des.Name);
            _groups    = new HashSet <string>(Util.Split(des.Group));
            if (_groups.Count == 0)
            {
                _groups.Add(Setting.DefualtGroup);
            }

            if (des.Index.IsEmpty())
            {
                Error("索引(Index)未填写");
            }
            ClassWrap cls = ClassWrap.Get(_fullName);

            _index = cls.Fields.Find(f => f.Name == des.Index);
            if (_index == null)
            {
                Error("配置主键字段不存在:" + des.Index);
                return;
            }
            _index.CreateKeyChecker();

            string path = Path.Combine(moduleDir, _des.DataPath);

            if (File.Exists(path))
            {
                _inputFiles = new string[] { path }
            }
            ;
            else if (Directory.Exists(path))
            {
                _inputFiles = Directory.GetFiles(path);
            }
            else
            {
                Error("数据路径不存在:" + path);
            }
            _outputFile = _fullName.Replace('.', '\\').ToLower();

            Add(this);
        }
Ejemplo n.º 7
0
        public ConstWrap(ClassWrap host, string name, string type, string value, string group, string desc, HashSet <string> gs)
        {
            _host     = host;
            _fullName = type;
            _name     = name;
            _value    = value;
            _desc     = desc;
            _groups   = gs;

            _group = group == null ? "" : group.ToLower();
            if (_groups == null)
            {
                _groups = new HashSet <string>(Util.Split(_group));
                if (_groups.Count == 0)
                {
                    _groups.Add(Setting.DefualtGroup);
                }
            }
        }
Ejemplo n.º 8
0
        public void VerifyData()
        {
            //数据表整列数据检查
            var cls    = ClassWrap.Get(_fullName);
            var fields = cls.Fields;

            for (int i = 0; i < fields.Count; i++)
            {
                var field    = fields[i];
                var checkers = field.Checkers;
                if (checkers == null)
                {
                    continue;
                }
                for (int k = 0; k < checkers.Count; k++)
                {
                    checkers[k].CheckColumn();
                }
            }
            _data.VerifyData();
        }
Ejemplo n.º 9
0
 public static bool IsRawOrEnumOrClass(string type)
 {
     return(Setting.RawTypes.Contains(type) ||
            EnumWrap.IsEnum(type) || ClassWrap.IsClass(type));
 }