Ejemplo n.º 1
0
 public DefFieldBase(DefTypeBase host, Field f, int idOffset)
 {
     HostType             = host;
     Id                   = f.Id + idOffset;
     AutoId               = Id;
     Name                 = f.Name;
     Type                 = f.Type;
     Comment              = f.Comment;
     Tags                 = DefUtil.ParseAttrs(f.Tags);
     IgnoreNameValidation = f.IgnoreNameValidation;
 }
Ejemplo n.º 2
0
 public DefTable(Table b)
 {
     Name             = b.Name;
     Namespace        = b.Namespace;
     Index            = b.Index;
     ValueType        = b.ValueType;
     Mode             = b.Mode;
     InputFiles       = b.InputFiles;
     Groups           = b.Groups;
     _patchInputFiles = b.PatchInputFiles;
     Comment          = b.Comment;
     Tags             = DefUtil.ParseAttrs(b.Tags);
     _outputFile      = b.OutputFile;
 }
Ejemplo n.º 3
0
 public DefBeanBase(Bean b)
 {
     Name              = b.Name;
     Namespace         = b.Namespace;
     Parent            = b.Parent;
     Id                = b.TypeId;
     IsValueType       = b.IsValueType;
     Comment           = b.Comment;
     Tags              = DefUtil.ParseAttrs(b.Tags);
     _externalTypeName = b.ExternalType;
     foreach (var field in b.Fields)
     {
         Fields.Add(CreateField(field, 0));
     }
 }
Ejemplo n.º 4
0
        public void Init()
        {
            SortSubTitles();
            Sep = Tags.TryGetValue("sep", out var sep) ? sep : "";
            //if (Tags.ContainsKey("sep"))
            //{
            //    throw new Exception($"字段名现在不支持sep,请移到##type行,例如'int&sep=;'");
            //}
            NonEmpty      = Tags.TryGetValue("non_empty", out var ne) && ne == "1";
            SelfMultiRows = Tags.TryGetValue("multi_rows", out var v2) && (v2 == "1" || v2 == "true");
            Default       = Tags.TryGetValue("default", out var v3) ? v3 : null;

            foreach (var(key, value) in Tags)
            {
                if (!s_validTags.Contains(key))
                {
                    throw new Exception($"excel标题列:'{Name}' 不支持tag:'{key}',请移到##type行");
                }
            }

            if (SubTitleList.Count > 0)
            {
                if (Root)
                {
                    var firstField = SubTitleList.FirstOrDefault(f => DefUtil.IsNormalFieldName(f.Name));
                    if (firstField != null)
                    {
                        // 第一个字段一般为key,为了避免失误将空单元格当作key=0的数据,默认非空
                        firstField.Tags.TryAdd("non_empty", "1");
                    }
                }
                foreach (var sub in SubTitleList)
                {
                    sub.Init();
                }
            }
            SubHierarchyMultiRows = SubTitleList.Any(t => t.HierarchyMultiRows);;
            HierarchyMultiRows    = SelfMultiRows || SubHierarchyMultiRows;
        }
Ejemplo n.º 5
0
 public static TEnum Create(bool isNullable, DefEnum defEnum, Dictionary <string, string> tags)
 {
     return(new TEnum(isNullable, DefUtil.MergeTags(defEnum.Tags, tags), defEnum));
 }
Ejemplo n.º 6
0
 public static TBean Create(bool isNullable, DefBeanBase defBean, Dictionary <string, string> tags)
 {
     // TODO
     return(new TBean(isNullable, DefUtil.MergeTags(defBean.Tags, tags), defBean));
 }
Ejemplo n.º 7
0
 public SetValidator(TType ttype, string param)
 {
     _type        = ttype;
     _datas       = new HashSet <DType>();
     _valueSetStr = DefUtil.TrimBracePairs(param);
 }