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; }
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; }
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)); } }
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; }
public static TEnum Create(bool isNullable, DefEnum defEnum, Dictionary <string, string> tags) { return(new TEnum(isNullable, DefUtil.MergeTags(defEnum.Tags, tags), defEnum)); }
public static TBean Create(bool isNullable, DefBeanBase defBean, Dictionary <string, string> tags) { // TODO return(new TBean(isNullable, DefUtil.MergeTags(defBean.Tags, tags), defBean)); }
public SetValidator(TType ttype, string param) { _type = ttype; _datas = new HashSet <DType>(); _valueSetStr = DefUtil.TrimBracePairs(param); }