public void Add(string insertPos, KeyPart part) { TextSpan span = null; foreach (var node in Child) { var key = node.Item1.Text.TrimEnd(']').Substring(2); if (key == insertPos) { span = node.Item1; } } if (span == null) { throw new Exception("没有找到对应的Key"); } ReplaceList.Add(new Tuple <TextSpan, KeyPart>(span, part)); }
public Generate(string templatePath) { var str = File.ReadAllText(templatePath); Tree = new KeyPart(new TextSpan(0, str.Length, str), str); }