/// <summary> /// 指定した設定ファイルの内容を解析します。 /// </summary> /// <param name="filePath"></param> public void Visit(string filePath) { SectionNode currentSection = null; File.ReadLines(filePath, ConfigDocument.Encoding) .Where(line => !string.IsNullOrWhiteSpace(line)) .ForEach(line => { if (CommentNode.IsComment(line)) { this.configNodeList.AddRange(this.VisitComment(new CommentNode(line))); } else if (SectionNode.IsSection(line)) { if (currentSection != null) { this.configNodeList.AddRange(this.VisitSection(currentSection)); currentSection = null; } currentSection = new SectionNode(line); } else { var newValueItemList = this.VisitValue(new ValueNode(line)); currentSection.ValueItemList.AddRange(newValueItemList); } }); if (currentSection != null) { this.configNodeList.AddRange(this.VisitSection(currentSection)); currentSection = null; } }
/// <summary> /// セクション要素を解析します。 /// </summary> /// <param name="section"></param> /// <returns></returns> protected virtual IEnumerable<SectionNode> VisitSection(SectionNode section) { return new[] { section }; }