/// <summary> /// 匹配文件 /// </summary> /// <param name="fileName"></param> /// <param name="option"></param> public void Match(IMatchCount matchCount, string fileName, IMatchOption option) { var allfileLines = File.ReadAllLines(fileName); var length = "ResourceManager.Default.GetResource(".Length; foreach (var line in allfileLines) { MatchCollection mc = errorStringRegx.Matches(line); foreach (Match m in mc) { matchCount.MatchesCount++; var tempValue = m.Value.Substring(length, m.Value.Length - length - 2); int index = tempValue.IndexOf(','); try { var key = ""; var value = ""; if (m.Value != "ResourceManager.Default.GetResource(\"\",\"\")") { key = tempValue.Substring(1, index - 2); value = tempValue.Substring(index + 3, tempValue.Length - index - 3); SkinAssistanceCommands.ShowDetailsInformationCommand.ExcuteCommand($"{m.Value}=>{key}<-->{value}"); } ResourceManager.Default.GetResource(key, value); } catch { SkinAssistanceCommands.ShowDetailsInformationCommand.ExcuteCommand($"{m.Value}=>{tempValue}!!!!!!"); } } } }
/// <summary> /// 匹配文件 /// </summary> /// <param name="fileName"></param> /// <param name="option"></param> public void Match(IMatchCount matchCount, string fileName, IMatchOption option) { var allfileLines = File.ReadAllLines(fileName); bool replaced = false; var newContent = new StringBuilder(); var fileShortName = Path.GetFileNameWithoutExtension(fileName); bool replceContent = false; var newFile = fileName; StringBuilder sb = new StringBuilder(); foreach (var line in allfileLines) { string source = line; Analyze: { replceContent = false; MatchCollection mc = errorStringRegx.Matches(source); foreach (Match m in mc) { matchCount.MatchesCount++; var strResource = m.Value.Substring(8, m.Length - 10); var matches = justStringRegx.Matches(strResource); foreach (Match c in matches) { sb.Append(c.Value.ToLower()); } var strResourceKey = sb.ToString(); sb.Clear(); replceContent = true; var resourceid = $"ResourceManager.Default.GetResource(\"{strResourceKey}\", \"{strResource}\")"; var replaceLink = $"Format({resourceid},"; source = source.Substring(0, m.Index) + replaceLink + source.Substring(m.Index + m.Length, source.Length - m.Index - m.Length); SkinAssistanceCommands.ShowDetailsInformationCommand.ExcuteCommand($"{m.Value}<=>{source}"); replaced = true; } if (replceContent) { goto Analyze; } } newContent.AppendLine(source); } if (replaced) { newFile.PrepaireDictoryInfo(); File.WriteAllText(newFile, newContent.ToString()); } newContent.Clear(); }
/// <summary> /// 匹配文件 /// </summary> /// <param name="fileName"></param> /// <param name="option"></param> public void Match(IMatchCount matchCount, string fileName, IMatchOption option) { }