【调整】自定义attrs改名为tags,相应测试函数也改为has_tag、get_tag
parent
2955cbac52
commit
6eb1a0d4f5
|
|
@ -260,12 +260,12 @@ namespace Luban.Job.Cfg.Defs
|
|||
string input = XmlUtil.GetRequiredAttribute(e, "input");
|
||||
string branchInput = XmlUtil.GetOptionalAttribute(e, "branch_input");
|
||||
string mode = XmlUtil.GetOptionalAttribute(e, "mode");
|
||||
string attrs = XmlUtil.GetOptionalAttribute(e, "attrs");
|
||||
AddTable(CurImportFile, name, module, valueType, index, mode, group, comment, defineFromFile, input, branchInput, attrs);
|
||||
string tags = XmlUtil.GetOptionalAttribute(e, "tags");
|
||||
AddTable(CurImportFile, name, module, valueType, index, mode, group, comment, defineFromFile, input, branchInput, tags);
|
||||
}
|
||||
|
||||
private void AddTable(string defineFile, string name, string module, string valueType, string index, string mode, string group,
|
||||
string comment, bool defineFromExcel, string input, string branchInput, string attrs)
|
||||
string comment, bool defineFromExcel, string input, string branchInput, string tags)
|
||||
{
|
||||
var p = new Table()
|
||||
{
|
||||
|
|
@ -277,7 +277,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
Groups = CreateGroups(group),
|
||||
Comment = comment,
|
||||
Mode = ConvertMode(name, mode, index),
|
||||
Attrs = attrs,
|
||||
Tags = tags,
|
||||
};
|
||||
|
||||
if (p.Groups.Count == 0)
|
||||
|
|
@ -329,7 +329,6 @@ namespace Luban.Job.Cfg.Defs
|
|||
{
|
||||
var cf = new CfgField() { Name = f.Name, Id = 0 };
|
||||
|
||||
|
||||
string[] attrs = (attrRow[f.FromIndex].Value?.ToString() ?? "").Trim().Split('&').Select(s => s.Trim()).ToArray();
|
||||
|
||||
if (attrs.Length == 0 || string.IsNullOrWhiteSpace(attrs[0]))
|
||||
|
|
@ -456,7 +455,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
new CfgField() { Name = "define_from_excel", Type = "bool" },
|
||||
new CfgField() { Name = "input", Type = "string" },
|
||||
new CfgField() { Name = "branch_input", Type = "string" },
|
||||
new CfgField() { Name = "attrs", Type = "string" },
|
||||
new CfgField() { Name = "tags", Type = "string" },
|
||||
}
|
||||
})
|
||||
{
|
||||
|
|
@ -491,8 +490,8 @@ namespace Luban.Job.Cfg.Defs
|
|||
bool isDefineFromExcel = (data.GetField("define_from_excel") as DBool).Value;
|
||||
string inputFile = (data.GetField("input") as DString).Value.Trim();
|
||||
string branchInput = (data.GetField("branch_input") as DString).Value.Trim();
|
||||
string attrs = (data.GetField("attrs") as DString).Value.Trim();
|
||||
AddTable(file.OriginFile, name, module, valueType, index, mode, group, comment, isDefineFromExcel, inputFile, branchInput, attrs);
|
||||
string tags = (data.GetField("tags") as DString).Value.Trim();
|
||||
AddTable(file.OriginFile, name, module, valueType, index, mode, group, comment, isDefineFromExcel, inputFile, branchInput, tags);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -522,7 +521,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
new CfgField() { Name = "alias", Type = "string" },
|
||||
new CfgField() { Name = "value", Type = "int" },
|
||||
new CfgField() { Name = "comment", Type = "string" },
|
||||
new CfgField() { Name = "attrs", Type = "string" },
|
||||
new CfgField() { Name = "tags", Type = "string" },
|
||||
}
|
||||
})
|
||||
{
|
||||
|
|
@ -566,8 +565,8 @@ namespace Luban.Job.Cfg.Defs
|
|||
string alias = (data.GetField("alias") as DString).Value.Trim();
|
||||
string value = (data.GetField("value") as DInt).Value.ToString();
|
||||
string comment = (data.GetField("comment") as DString).Value.Trim();
|
||||
string attrs = (data.GetField("attrs") as DString).Value.Trim();
|
||||
curEnum.Items.Add(new EnumItem() { Name = item, Alias = alias, Value = value, Comment = comment, Attrs = attrs });
|
||||
string tags = (data.GetField("tags") as DString).Value.Trim();
|
||||
curEnum.Items.Add(new EnumItem() { Name = item, Alias = alias, Value = value, Comment = comment, Tags = tags });
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -604,7 +603,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
new CfgField() { Name = "reference", Type = "string" },
|
||||
new CfgField() { Name = "path", Type = "string" },
|
||||
new CfgField() { Name = "comment", Type = "string" },
|
||||
new CfgField() { Name = "attrs", Type = "string" },
|
||||
new CfgField() { Name = "tags", Type = "string" },
|
||||
}
|
||||
})
|
||||
{
|
||||
|
|
@ -632,7 +631,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
new CfgField() { Name = "full_name", Type = "string" },
|
||||
new CfgField() { Name = "sep", Type = "string" },
|
||||
new CfgField() { Name = "comment", Type = "string" },
|
||||
new CfgField() { Name = "attrs", Type = "string" },
|
||||
new CfgField() { Name = "tags", Type = "string" },
|
||||
new CfgField() { Name = "fields", Type = "list,__FieldInfo__", IsMultiRow = true },
|
||||
}
|
||||
})
|
||||
|
|
@ -667,7 +666,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
|
||||
string sep = (data.GetField("sep") as DString).Value.Trim();
|
||||
string comment = (data.GetField("comment") as DString).Value.Trim();
|
||||
string attrs = (data.GetField("attrs") as DString).Value.Trim();
|
||||
string tags = (data.GetField("tags") as DString).Value.Trim();
|
||||
DList fields = data.GetField("fields") as DList;
|
||||
var curBean = new CfgBean()
|
||||
{
|
||||
|
|
@ -675,7 +674,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
Namespace = module,
|
||||
Sep = sep,
|
||||
Comment = comment,
|
||||
Attrs = attrs,
|
||||
Tags = tags,
|
||||
Parent = "",
|
||||
Fields = fields.Datas.Select(d => (DBean)d).Select(b => this.CreateField(
|
||||
(b.GetField("name") as DString).Value.Trim(),
|
||||
|
|
@ -693,7 +692,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
"",
|
||||
"",
|
||||
"",
|
||||
(b.GetField("attrs") as DString).Value.Trim()
|
||||
(b.GetField("tags") as DString).Value.Trim()
|
||||
)).ToList(),
|
||||
};
|
||||
this._beans.Add(curBean);
|
||||
|
|
@ -709,7 +708,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
|
||||
private static readonly List<string> _fieldOptionalAttrs = new List<string> {
|
||||
"index", "sep", "validator", "key_validator", "value_validator",
|
||||
"ref", "path", "range", "multi_rows", "group", "res", "convert", "comment", "attrs" };
|
||||
"ref", "path", "range", "multi_rows", "group", "res", "convert", "comment", "tags" };
|
||||
|
||||
private static readonly List<string> _fieldRequireAttrs = new List<string> { "name", "type" };
|
||||
|
||||
|
|
@ -732,12 +731,12 @@ namespace Luban.Job.Cfg.Defs
|
|||
XmlUtil.GetOptionalAttribute(e, "key_validator"),
|
||||
XmlUtil.GetOptionalAttribute(e, "value_validator"),
|
||||
XmlUtil.GetOptionalAttribute(e, "validator"),
|
||||
XmlUtil.GetOptionalAttribute(e, "attrs")
|
||||
XmlUtil.GetOptionalAttribute(e, "tags")
|
||||
);
|
||||
}
|
||||
|
||||
private Field CreateField(string name, string type, string index, string sep, bool isMultiRow, string group, string resource, string converter,
|
||||
string comment, string refs, string path, string range, string keyValidator, string valueValidator, string validator, string attrs)
|
||||
string comment, string refs, string path, string range, string keyValidator, string valueValidator, string validator, string tags)
|
||||
{
|
||||
var f = new CfgField()
|
||||
{
|
||||
|
|
@ -749,7 +748,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
Resource = resource,
|
||||
Converter = converter,
|
||||
Comment = comment,
|
||||
Attrs = attrs,
|
||||
Tags = tags,
|
||||
};
|
||||
|
||||
// 字段与table的默认组不一样。
|
||||
|
|
@ -776,7 +775,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
return f;
|
||||
}
|
||||
|
||||
private static readonly List<string> _beanOptinsAttrs = new List<string> { "value_type", "alias", "sep", "comment", "attrs" };
|
||||
private static readonly List<string> _beanOptinsAttrs = new List<string> { "value_type", "alias", "sep", "comment", "tags" };
|
||||
private static readonly List<string> _beanRequireAttrs = new List<string> { "name" };
|
||||
|
||||
protected override void AddBean(XElement e, string parent)
|
||||
|
|
@ -794,7 +793,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
Alias = XmlUtil.GetOptionalAttribute(e, "alias"),
|
||||
Sep = XmlUtil.GetOptionalAttribute(e, "sep"),
|
||||
Comment = XmlUtil.GetOptionalAttribute(e, "comment"),
|
||||
Attrs = XmlUtil.GetOptionalAttribute(e, "attrs"),
|
||||
Tags = XmlUtil.GetOptionalAttribute(e, "tags"),
|
||||
};
|
||||
var childBeans = new List<XElement>();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
Groups = b.Groups;
|
||||
_branchInputFiles = b.BranchInputFiles;
|
||||
Comment = b.Comment;
|
||||
Attrs = DefUtil.ParseAttrs(b.Attrs);
|
||||
Tags = DefUtil.ParseAttrs(b.Tags);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Luban.Job.Cfg.RawDefs
|
|||
|
||||
public string Comment { get; set; }
|
||||
|
||||
public string Attrs { get; set; }
|
||||
public string Tags { get; set; }
|
||||
|
||||
public List<string> Groups { get; set; } = new List<string>();
|
||||
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ namespace Luban.Job.Common.Defs
|
|||
}
|
||||
|
||||
private static readonly List<string> _fieldRequireAttrs = new List<string> { "name", "type", };
|
||||
private static readonly List<string> _fieldOptionalAttrs = new List<string> { "id", "comment", "attrs" };
|
||||
private static readonly List<string> _fieldOptionalAttrs = new List<string> { "id", "comment", "tags" };
|
||||
|
||||
protected virtual Field CreateField(XElement e)
|
||||
{
|
||||
|
|
@ -206,7 +206,7 @@ namespace Luban.Job.Common.Defs
|
|||
Name = XmlUtil.GetRequiredAttribute(e, "name"),
|
||||
Type = CreateType(e, "type"),
|
||||
Comment = XmlUtil.GetOptionalAttribute(e, "comment"),
|
||||
Attrs = XmlUtil.GetOptionalAttribute(e, "attrs"),
|
||||
Tags = XmlUtil.GetOptionalAttribute(e, "tags"),
|
||||
};
|
||||
return f;
|
||||
}
|
||||
|
|
@ -216,10 +216,10 @@ namespace Luban.Job.Common.Defs
|
|||
AddBean(e, "");
|
||||
}
|
||||
|
||||
private static readonly List<string> _beanOptinsAttrs1 = new List<string> { "compatible", "value_type", "comment", "attrs" };
|
||||
private static readonly List<string> _beanOptinsAttrs1 = new List<string> { "compatible", "value_type", "comment", "tags" };
|
||||
private static readonly List<string> _beanRequireAttrs1 = new List<string> { "id", "name" };
|
||||
|
||||
private static readonly List<string> _beanOptinsAttrs2 = new List<string> { "id", "compatible", "value_type", "comment", "attrs" };
|
||||
private static readonly List<string> _beanOptinsAttrs2 = new List<string> { "id", "compatible", "value_type", "comment", "tags" };
|
||||
private static readonly List<string> _beanRequireAttrs2 = new List<string> { "name" };
|
||||
|
||||
protected virtual void AddBean(XElement e, string parent)
|
||||
|
|
@ -241,7 +241,7 @@ namespace Luban.Job.Common.Defs
|
|||
IsSerializeCompatible = XmlUtil.GetOptionBoolAttribute(e, "compatible", IsBeanDefaultCompatible),
|
||||
IsValueType = XmlUtil.GetOptionBoolAttribute(e, "value_type"),
|
||||
Comment = XmlUtil.GetOptionalAttribute(e, "comment"),
|
||||
Attrs = XmlUtil.GetOptionalAttribute(e, "attrs"),
|
||||
Tags = XmlUtil.GetOptionalAttribute(e, "tags"),
|
||||
};
|
||||
var childBeans = new List<XElement>();
|
||||
|
||||
|
|
@ -336,11 +336,11 @@ namespace Luban.Job.Common.Defs
|
|||
_consts.Add(c);
|
||||
}
|
||||
|
||||
private static readonly List<string> _enumOptionalAttrs = new List<string> { "flags", "comment", "attrs" };
|
||||
private static readonly List<string> _enumOptionalAttrs = new List<string> { "flags", "comment", "tags" };
|
||||
private static readonly List<string> _enumRequiredAttrs = new List<string> { "name" };
|
||||
|
||||
|
||||
private static readonly List<string> _enumItemOptionalAttrs = new List<string> { "value", "alias", "comment", "attrs" };
|
||||
private static readonly List<string> _enumItemOptionalAttrs = new List<string> { "value", "alias", "comment", "tags" };
|
||||
private static readonly List<string> _enumItemRequiredAttrs = new List<string> { "name" };
|
||||
|
||||
protected void AddEnum(XElement e)
|
||||
|
|
@ -352,7 +352,7 @@ namespace Luban.Job.Common.Defs
|
|||
Namespace = CurNamespace,
|
||||
Comment = XmlUtil.GetOptionalAttribute(e, "comment"),
|
||||
IsFlags = XmlUtil.GetOptionBoolAttribute(e, "flags"),
|
||||
Attrs = XmlUtil.GetOptionalAttribute(e, "attrs"),
|
||||
Tags = XmlUtil.GetOptionalAttribute(e, "tags"),
|
||||
};
|
||||
|
||||
foreach (XElement item in e.Elements())
|
||||
|
|
@ -364,7 +364,7 @@ namespace Luban.Job.Common.Defs
|
|||
Alias = XmlUtil.GetOptionalAttribute(item, "alias"),
|
||||
Value = XmlUtil.GetOptionalAttribute(item, "value"),
|
||||
Comment = XmlUtil.GetOptionalAttribute(item, "comment"),
|
||||
Attrs = XmlUtil.GetOptionalAttribute(item, "attrs"),
|
||||
Tags = XmlUtil.GetOptionalAttribute(item, "tags"),
|
||||
});
|
||||
}
|
||||
s_logger.Trace("add enum:{@enum}", en);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ namespace Luban.Job.Common.Defs
|
|||
protected TType CreateNotContainerType(string module, string rawType)
|
||||
{
|
||||
bool nullable;
|
||||
var (type, attrs) = DefUtil.ParseType(rawType);
|
||||
var (type, tags) = DefUtil.ParseType(rawType);
|
||||
|
||||
if (type.EndsWith('?'))
|
||||
{
|
||||
|
|
@ -149,33 +149,33 @@ namespace Luban.Job.Common.Defs
|
|||
}
|
||||
switch (type)
|
||||
{
|
||||
case "bool": return attrs == null ? (nullable ? TBool.NullableIns : TBool.Ins) : new TBool(nullable) { Attrs = attrs };
|
||||
case "bool": return tags == null ? (nullable ? TBool.NullableIns : TBool.Ins) : new TBool(nullable) { Tags = tags };
|
||||
case "uint8":
|
||||
case "byte": return attrs == null ? (nullable ? TByte.NullableIns : TByte.Ins) : new TByte(nullable) { Attrs = attrs };
|
||||
case "byte": return tags == null ? (nullable ? TByte.NullableIns : TByte.Ins) : new TByte(nullable) { Tags = tags };
|
||||
case "int16":
|
||||
case "short": return attrs == null ? (nullable ? TShort.NullableIns : TShort.Ins) : new TShort(nullable) { Attrs = attrs };
|
||||
case "short": return tags == null ? (nullable ? TShort.NullableIns : TShort.Ins) : new TShort(nullable) { Tags = tags };
|
||||
case "fint16":
|
||||
case "fshort": return attrs == null ? (nullable ? TFshort.NullableIns : TFshort.Ins) : new TFshort(nullable) { Attrs = attrs };
|
||||
case "fshort": return tags == null ? (nullable ? TFshort.NullableIns : TFshort.Ins) : new TFshort(nullable) { Tags = tags };
|
||||
case "int32":
|
||||
case "int": return attrs == null ? (nullable ? TInt.NullableIns : TInt.Ins) : new TInt(nullable) { Attrs = attrs };
|
||||
case "int": return tags == null ? (nullable ? TInt.NullableIns : TInt.Ins) : new TInt(nullable) { Tags = tags };
|
||||
case "fint32":
|
||||
case "fint": return attrs == null ? (nullable ? TFint.NullableIns : TFint.Ins) : new TFint(nullable) { Attrs = attrs };
|
||||
case "fint": return tags == null ? (nullable ? TFint.NullableIns : TFint.Ins) : new TFint(nullable) { Tags = tags };
|
||||
case "int64":
|
||||
case "long": return attrs == null ? (nullable ? TLong.NullableIns : TLong.Ins) : new TLong(nullable, false) { Attrs = attrs };
|
||||
case "bigint": return attrs == null ? (nullable ? TLong.NullableBigIns : TLong.BigIns) : new TLong(nullable, true) { Attrs = attrs };
|
||||
case "long": return tags == null ? (nullable ? TLong.NullableIns : TLong.Ins) : new TLong(nullable, false) { Tags = tags };
|
||||
case "bigint": return tags == null ? (nullable ? TLong.NullableBigIns : TLong.BigIns) : new TLong(nullable, true) { Tags = tags };
|
||||
case "fint64":
|
||||
case "flong": return attrs == null ? (nullable ? TFlong.NullableIns : TFlong.Ins) : new TFlong(nullable) { Attrs = attrs };
|
||||
case "flong": return tags == null ? (nullable ? TFlong.NullableIns : TFlong.Ins) : new TFlong(nullable) { Tags = tags };
|
||||
case "float32":
|
||||
case "float": return attrs == null ? (nullable ? TFloat.NullableIns : TFloat.Ins) : new TFloat(nullable) { Attrs = attrs };
|
||||
case "float": return tags == null ? (nullable ? TFloat.NullableIns : TFloat.Ins) : new TFloat(nullable) { Tags = tags };
|
||||
case "float64":
|
||||
case "double": return attrs == null ? (nullable ? TDouble.NullableIns : TDouble.Ins) : new TDouble(nullable) { Attrs = attrs };
|
||||
case "bytes": return attrs == null ? (nullable ? new TBytes(true) : TBytes.Ins) : new TBytes(false) { Attrs = attrs };
|
||||
case "string": return attrs == null ? (nullable ? TString.NullableIns : TString.Ins) : new TString(nullable) { Attrs = attrs };
|
||||
case "text": return attrs == null ? (nullable ? TText.NullableIns : TText.Ins) : new TText(nullable) { Attrs = attrs };
|
||||
case "vector2": return attrs == null ? (nullable ? TVector2.NullableIns : TVector2.Ins) : new TVector2(nullable) { Attrs = attrs };
|
||||
case "vector3": return attrs == null ? (nullable ? TVector3.NullableIns : TVector3.Ins) : new TVector3(nullable) { Attrs = attrs };
|
||||
case "vector4": return attrs == null ? (nullable ? TVector4.NullableIns : TVector4.Ins) : new TVector4(nullable) { Attrs = attrs };
|
||||
case "datetime": return SupportDatetimeType ? (attrs == null ? (nullable ? TDateTime.NullableIns : TDateTime.Ins) : new TDateTime(nullable) { Attrs = attrs }) : throw new NotSupportedException($"只有配置支持datetime数据类型");
|
||||
case "double": return tags == null ? (nullable ? TDouble.NullableIns : TDouble.Ins) : new TDouble(nullable) { Tags = tags };
|
||||
case "bytes": return tags == null ? (nullable ? new TBytes(true) : TBytes.Ins) : new TBytes(false) { Tags = tags };
|
||||
case "string": return tags == null ? (nullable ? TString.NullableIns : TString.Ins) : new TString(nullable) { Tags = tags };
|
||||
case "text": return tags == null ? (nullable ? TText.NullableIns : TText.Ins) : new TText(nullable) { Tags = tags };
|
||||
case "vector2": return tags == null ? (nullable ? TVector2.NullableIns : TVector2.Ins) : new TVector2(nullable) { Tags = tags };
|
||||
case "vector3": return tags == null ? (nullable ? TVector3.NullableIns : TVector3.Ins) : new TVector3(nullable) { Tags = tags };
|
||||
case "vector4": return tags == null ? (nullable ? TVector4.NullableIns : TVector4.Ins) : new TVector4(nullable) { Tags = tags };
|
||||
case "datetime": return SupportDatetimeType ? (tags == null ? (nullable ? TDateTime.NullableIns : TDateTime.Ins) : new TDateTime(nullable) { Tags = tags }) : throw new NotSupportedException($"只有配置支持datetime数据类型");
|
||||
default:
|
||||
{
|
||||
var dtype = GetDefTType(module, type, nullable);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace Luban.Job.Common.Defs
|
|||
Id = b.TypeId;
|
||||
IsValueType = b.IsValueType;
|
||||
Comment = b.Comment;
|
||||
Attrs = DefUtil.ParseAttrs(b.Attrs);
|
||||
Tags = DefUtil.ParseAttrs(b.Tags);
|
||||
foreach (var field in b.Fields)
|
||||
{
|
||||
Fields.Add(CreateField(field, 0));
|
||||
|
|
|
|||
|
|
@ -23,16 +23,16 @@ namespace Luban.Job.Common.Defs
|
|||
|
||||
public string Comment { get; init; }
|
||||
|
||||
public Dictionary<string, string> Attrs { get; init; }
|
||||
public Dictionary<string, string> Tags { get; init; }
|
||||
|
||||
public bool HasAttr(string attrName)
|
||||
public bool HasTag(string attrName)
|
||||
{
|
||||
return Attrs != null && Attrs.ContainsKey(attrName);
|
||||
return Tags != null && Tags.ContainsKey(attrName);
|
||||
}
|
||||
|
||||
public string GetAttr(string attrName)
|
||||
public string GetTag(string attrName)
|
||||
{
|
||||
return Attrs != null && Attrs.TryGetValue(attrName, out var value) ? value : null;
|
||||
return Tags != null && Tags.TryGetValue(attrName, out var value) ? value : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ namespace Luban.Job.Common.Defs
|
|||
IsFlags = e.IsFlags;
|
||||
IsUniqueItemId = e.IsUniqueItemId;
|
||||
Comment = e.Comment;
|
||||
Attrs = DefUtil.ParseAttrs(e.Attrs);
|
||||
Tags = DefUtil.ParseAttrs(e.Tags);
|
||||
|
||||
foreach (var item in e.Items)
|
||||
{
|
||||
|
|
@ -95,7 +95,7 @@ namespace Luban.Job.Common.Defs
|
|||
Alias = item.Alias,
|
||||
Value = item.Value,
|
||||
Comment = string.IsNullOrWhiteSpace(item.Comment) ? item.Alias : item.Comment,
|
||||
Attrs = DefUtil.ParseAttrs(item.Attrs),
|
||||
Tags = DefUtil.ParseAttrs(item.Tags),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,16 +72,16 @@ namespace Luban.Job.Common.Defs
|
|||
|
||||
public string Comment { get; }
|
||||
|
||||
public Dictionary<string, string> Attrs { get; }
|
||||
public Dictionary<string, string> Tags { get; }
|
||||
|
||||
public bool HasAttr(string attrName)
|
||||
public bool HasTag(string attrName)
|
||||
{
|
||||
return Attrs != null && Attrs.ContainsKey(attrName);
|
||||
return Tags != null && Tags.ContainsKey(attrName);
|
||||
}
|
||||
|
||||
public string GetAttr(string attrName)
|
||||
public string GetTag(string attrName)
|
||||
{
|
||||
return Attrs != null && Attrs.TryGetValue(attrName, out var value) ? value : null;
|
||||
return Tags != null && Tags.TryGetValue(attrName, out var value) ? value : null;
|
||||
}
|
||||
|
||||
public DefFieldBase(DefTypeBase host, Field f, int idOffset)
|
||||
|
|
@ -91,7 +91,7 @@ namespace Luban.Job.Common.Defs
|
|||
Name = f.Name;
|
||||
Type = f.Type;
|
||||
Comment = f.Comment;
|
||||
Attrs = DefUtil.ParseAttrs(f.Attrs);
|
||||
Tags = DefUtil.ParseAttrs(f.Tags);
|
||||
}
|
||||
|
||||
public virtual void Compile()
|
||||
|
|
|
|||
|
|
@ -46,16 +46,16 @@ namespace Luban.Job.Common.Defs
|
|||
|
||||
public string Comment { get; protected set; }
|
||||
|
||||
public Dictionary<string, string> Attrs { get; protected set; }
|
||||
public Dictionary<string, string> Tags { get; protected set; }
|
||||
|
||||
public bool HasAttr(string attrName)
|
||||
public bool HasTag(string attrName)
|
||||
{
|
||||
return Attrs != null && Attrs.ContainsKey(attrName);
|
||||
return Tags != null && Tags.ContainsKey(attrName);
|
||||
}
|
||||
|
||||
public string GetAttr(string attrName)
|
||||
public string GetTag(string attrName)
|
||||
{
|
||||
return Attrs != null && Attrs.TryGetValue(attrName, out var value) ? value : null;
|
||||
return Tags != null && Tags.TryGetValue(attrName, out var value) ? value : null;
|
||||
}
|
||||
|
||||
public virtual void PreCompile() { }
|
||||
|
|
|
|||
|
|
@ -163,14 +163,14 @@ namespace Luban.Job.Common.Defs
|
|||
return type.Apply(LuaConstValueVisitor.Ins, value);
|
||||
}
|
||||
|
||||
public static bool HasAttr(dynamic obj, string attrName)
|
||||
public static bool HasTag(dynamic obj, string attrName)
|
||||
{
|
||||
return obj.HasAttr(attrName);
|
||||
return obj.HasTag(attrName);
|
||||
}
|
||||
|
||||
public static string GetAttr(dynamic obj, string attrName)
|
||||
public static string GetTag(dynamic obj, string attrName)
|
||||
{
|
||||
return obj.GetAttr(attrName);
|
||||
return obj.GetTag(attrName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Luban.Job.Common.RawDefs
|
|||
|
||||
public string Comment { get; set; }
|
||||
|
||||
public string Attrs { get; set; }
|
||||
public string Tags { get; set; }
|
||||
|
||||
public List<Field> Fields { get; set; } = new List<Field>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ namespace Luban.Job.Common.RawDefs
|
|||
|
||||
public string Comment { get; set; }
|
||||
|
||||
public string Attrs { get; set; }
|
||||
public string Tags { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Luban.Job.Common.RawDefs
|
|||
|
||||
public string Comment { get; set; }
|
||||
|
||||
public string Attrs { get; set; }
|
||||
public string Tags { get; set; }
|
||||
}
|
||||
|
||||
public class PEnum
|
||||
|
|
@ -28,7 +28,7 @@ namespace Luban.Job.Common.RawDefs
|
|||
|
||||
public string Comment { get; set; }
|
||||
|
||||
public string Attrs { get; set; }
|
||||
public string Tags { get; set; }
|
||||
|
||||
public List<EnumItem> Items { get; set; } = new List<EnumItem>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,16 +12,16 @@ namespace Luban.Job.Common.Types
|
|||
IsNullable = isNullable;
|
||||
}
|
||||
|
||||
public Dictionary<string, string> Attrs { get; set; }
|
||||
public Dictionary<string, string> Tags { get; set; }
|
||||
|
||||
public bool HasAttr(string attrName)
|
||||
public bool HasTag(string attrName)
|
||||
{
|
||||
return Attrs != null && Attrs.ContainsKey(attrName);
|
||||
return Tags != null && Tags.ContainsKey(attrName);
|
||||
}
|
||||
|
||||
public string GetAttr(string attrName)
|
||||
public string GetTag(string attrName)
|
||||
{
|
||||
return Attrs != null && Attrs.TryGetValue(attrName, out var value) ? value : null;
|
||||
return Tags != null && Tags.TryGetValue(attrName, out var value) ? value : null;
|
||||
}
|
||||
|
||||
public abstract bool TryParseFrom(string s);
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ namespace Luban.Job.Common.Utils
|
|||
|
||||
private readonly static char[] s_attrKeyValueSep = new char[] { '=', ':' };
|
||||
|
||||
public static Dictionary<string, string> ParseAttrs(string attrs)
|
||||
public static Dictionary<string, string> ParseAttrs(string tags)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(attrs))
|
||||
if (string.IsNullOrWhiteSpace(tags))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var am = new Dictionary<string, string>();
|
||||
foreach (var pair in attrs.Split(s_attrSep))
|
||||
foreach (var pair in tags.Split(s_attrSep))
|
||||
{
|
||||
int sepIndex = pair.IndexOfAny(s_attrKeyValueSep);
|
||||
if (sepIndex >= 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue