/// <summary> /// Add the current folder to the list and move on to the next. /// </summary> private void AddCurrentFolder() { if (currentFolder != null) { // check required options: if (currentFolder.Name == null) { throw ReadError("Folder without name."); } if (currentFolder.Path == null) { throw ReadError("Expected 'path = value' option for folder: " + currentFolder.Name); } if (currentFolder.Executable == null) { throw ReadError("Expected 'executable = value' option for folder: " + currentFolder.Name); } // create and add the new folder: Folder folder = new Folder( currentFolder.Name, currentFolder.Path, currentFolder.Executable, currentFolder.Extensions, currentFolder.Parameters, currentFolder.WorkingDirectory ); folders.Add(folder); currentFolder = null; } }
/// <summary> /// An INIReader that reads lines from a folders file /// adding sections and key=value pairs to a collection /// as folder names/options. /// </summary> public FoldersFileReader() { filepath = null; folders = null; seenFolderNames = new HashSet <String>(); currentFolder = null; currentLineNumber = 0; currentLine = String.Empty; }
/// <summary> /// Clear internal state. /// </summary> private void ResetState() { filepath = null; folders = null; seenFolderNames.Clear(); currentFolder = null; currentLineNumber = 0; currentLine = String.Empty; }
/// <summary> /// An INIReader that reads lines from a folders file /// adding sections and key=value pairs to a collection /// as folder names/options. /// </summary> public FoldersFileReader() { filepath = null; folders = null; seenFolderNames = new HashSet<String>(); currentFolder = null; currentLineNumber = 0; currentLine = String.Empty; }
/// <summary> /// On a new section, add the current folder to the collection /// and create the next one. /// </summary> protected override void OnSection(String section) { AddCurrentFolder(); // folder names must be unique: String name = section; if (seenFolderNames.Contains(name)) { throw ReadError("Duplicate folder name: " + name); } seenFolderNames.Add(name); currentFolder = new FoldersFileReaderFolder(); currentFolder.Name = name; }