/// <summary> /// Returns a section object from the specified path. /// </summary> /// <param name="path">The path of the section to return.</param> /// <returns></returns> public ConfigSection GetSectionFromPath(string path) { string fullPath = "__global__." + path; if (!DefinedSections.ContainsKey(fullPath)) { throw new SectionNotFoundException(path); } return(DefinedSections[fullPath]); }
/// <summary> /// Adds a variable to the specified section. /// </summary> /// <param name="variable">The variable object to add.</param> /// <param name="section">The section to add the variable to (leave empty for global section).</param> /// <exception cref="SectionNotFoundException"></exception> /// <exception cref="InvalidIdentifierNameException"></exception> public void AddVariable(ConfigVariable variable, string section = "") { CheckIdentifier(variable.Name); if (section == "") { DefinedSections["__global__"].Variables[variable.Name] = variable; } else { if (!DefinedSections.ContainsKey("__global__." + section)) { throw new SectionNotFoundException(section); } DefinedSections["__global__." + section].Variables[variable.Name] = variable; } }