public void Run() { List <Dictionary <string, string> > dataList = new List <Dictionary <string, string> >(); string content = File.ReadAllText(Setting.Options.TextCodeTS); string pattern = "static[ \t]*(.*)[ \t]*=[ \t]*\"(.*)\"[ \t]*;"; int id = 1; foreach (Match match in Regex.Matches(content, pattern)) { string key = match.Groups[1].ToString().Trim(); string value = match.Groups[2].ToString().Trim(); Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("id", id.ToString()); dict.Add("key", key); dict.Add("zh_cn_value", value); dataList.Add(dict); id++; } List <DataField> fields = new List <DataField>(); DataField field = new DataField(); field.typeName = "int"; field.cn = "ID"; field.field = "id"; fields.Add(field); field = new DataField(); field.typeName = "string"; field.cn = "Key"; field.field = "key"; fields.Add(field); field = new DataField(); field.typeName = "string"; field.cn = "值"; field.field = "zh_cn_value"; fields.Add(field); LangTableData langTableData = new LangTableData(); langTableData.langPath = Setting.Options.TextCodeXlsx; langTableData.idKey = "key"; langTableData.ReaderLangTable(); langTableData.SetFields(fields); langTableData.SetDataList(dataList); langTableData.Sort("id"); langTableData.ResetGenerateID(); langTableData.Save(); }
public void Generate() { foreach (var kvp in xlsxManager.tables) { TableReader table = kvp.Value; if (!table.hasLangField) { continue; } string langPath = Setting.Options.langDir + "/editor/" + table.tableName + ".xlsx"; LangTableData langTableData = new LangTableData(); langTableData.langPath = langPath; langTableData.ReaderLangTable(); langTableData.SetFields(table.dataStruct.fields); langTableData.SetDataList(table.dataList); langTableData.Sort("id"); langTableData.Save(); } }
public void Run() { List <Dictionary <string, string> > dataList = new List <Dictionary <string, string> >(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(Setting.Options.TextFguiXml); XmlNode resources = xmlDocument.SelectSingleNode(@"resources"); XmlNodeList xmlNodeList = resources.ChildNodes; int id = 1; string comment = string.Empty; foreach (XmlNode node in xmlNodeList) { switch (node.NodeType) { case XmlNodeType.Comment: comment = node.InnerText.Trim(); Console.WriteLine(comment); break; case XmlNodeType.Element: string name = node.Attributes.GetNamedItem("name").InnerText; string mz = node.Attributes.GetNamedItem("mz").InnerText; string value = node.InnerText.Trim(); Console.WriteLine($"name={name}, mz={mz}, value={value}"); Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("id", id.ToString()); dict.Add("comment", comment); dict.Add("name", name); dict.Add("mz", mz); dict.Add("zh_cn_value", value); dataList.Add(dict); id++; break; } } List <DataField> fields = new List <DataField>(); DataField field = new DataField(); field.typeName = "int"; field.cn = "ID"; field.field = "id"; fields.Add(field); field = new DataField(); field.typeName = "string"; field.cn = "备注"; field.field = "comment"; fields.Add(field); field = new DataField(); field.typeName = "string"; field.cn = "UI编号"; field.field = "name"; fields.Add(field); field = new DataField(); field.typeName = "string"; field.cn = "UI元件名称"; field.field = "mz"; fields.Add(field); field = new DataField(); field.typeName = "string"; field.cn = "值"; field.field = "zh_cn_value"; fields.Add(field); LangTableData langTableData = new LangTableData(); langTableData.langPath = Setting.Options.TextFguiXlsx; langTableData.idKey = "name"; langTableData.ReaderLangTable(); langTableData.SetFields(fields); langTableData.SetDataList(dataList); langTableData.Sort("id"); langTableData.ResetGenerateID(); langTableData.Save(); }