public void Load(TextReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } this.sections.Clear(); SSASection section = null; while (true) { string line = reader.ReadLine(); if (line == null) { break; } Regex regex = new Regex(@"^\s*\[(?<Name>[^\]]+)\]\s*$"); Match match = regex.Match(line); if (match.Success) { // 节的开始 if (section != null) { this.sections.Add(section); } section = this.CreateNamedSection(match.Groups["Name"].Value); } else { if (section == null) { section = new SSASection(); // 创建一个匿名节。 } section.Add(line); } } if (section != null) { this.sections.Add(section); } }
public virtual SSASection CreateSection(string name = null) { SSASection section; if (name == null) { section = new SSASection(); } else if (name == "Script Info") { section = this.ScriptInfo; } else { section = this.CreateNamedSection(name); } this.sections.Add(section); return(section); }