public ChoIniSectionNode AddSection(string sectionName) { if (Contains(sectionName)) { throw new ChoIniDocumentException(String.Format("Failed to add `{0}` section. Found duplicate node. Please check in the INI document and its sub-documents.", sectionName)); } ChoIniSectionNode iniSection = new ChoIniSectionNode(this.OwnerDocument, sectionName); iniSection._parentIniSectionNode = this; return(AddIniNode(iniSection) as ChoIniSectionNode); }
internal bool AddSection(ChoIniSectionNode iniSectionNode) { ChoGuard.ArgumentNotNullOrEmpty(iniSectionNode, "IniSectionNode"); if (Contains(iniSectionNode.Name)) { throw new ChoIniDocumentException(String.Format("Failed to add duplicate '{0}' section. Please check in the INI document and its sub-documents.", iniSectionNode.Name)); } iniSectionNode._parentIniSectionNode = this; return(AddIniNode(iniSectionNode) != null); }
public void UncommentSection(string sectionName) { ChoIniSectionNode foundSection = GetSection(sectionName); if (foundSection == null) { throw new ChoIniDocumentException(String.Format("Can't find `{0}` section.", sectionName)); } else { UncommentSection(foundSection); } }
//public bool InsertBeforeSection(string sectionName, ChoIniSectionNode iniSectionNode) //{ // ChoGuard.ArgumentNotNullOrEmpty(sectionName, "SectionName"); // ChoGuard.ArgumentNotNullOrEmpty(iniSectionNode, "IniSectionNode"); // ChoIniSectionNode insertBeforeSection = null; // if (!TryGetSection(sectionName, out insertBeforeSection)) // throw new ChoIniDocumentException(String.Format("Can't find {0} section.", sectionName)); // else // return InsertBeforeIniNode(GetIndex(insertBeforeSection), iniSectionNode); //} //public bool InsertAfterSection(string sectionName, ChoIniSectionNode iniSectionNode) //{ // ChoGuard.ArgumentNotNullOrEmpty(sectionName, "SectionName"); // ChoGuard.ArgumentNotNullOrEmpty(iniSectionNode, "IniSectionNode"); // ChoIniSectionNode insertBeforeSection = null; // if (!TryGetSection(sectionName, out insertBeforeSection)) // throw new ChoIniDocumentException(String.Format("Can't find {0} section.", sectionName)); // else // return InsertBeforeIniNode(GetIndex(insertBeforeSection), iniSectionNode); //} //public ChoIniSectionNode CreateSection(string sectionName) //{ // if (Contains(sectionName)) // throw new ChoIniDocumentException(String.Format("Duplicate `{0}` section found. Please check in the INI document and its sub-documents.", sectionName)); // ChoIniSectionNode iniSection = new ChoIniSectionNode(this.OwnerDocument, sectionName); // iniSection._parentIniSectionNode = this; // return iniSection; //} public bool DeleteSection(string sectionName) { ChoIniSectionNode foundSection = GetSection(sectionName); if (foundSection == null) { throw new ChoIniDocumentException(String.Format("Can't find `{0}` section.", sectionName)); } else { return(DeleteSection(foundSection)); } }
private string GetName() { StringBuilder name = new StringBuilder(); ChoIniSectionNode iniSectionNode = this; name.Append(_name); while (iniSectionNode._parentIniSectionNode != null) { if (iniSectionNode._parentIniSectionNode.IsRootSection) { break; } name.Insert(0, '/'); name.Insert(0, iniSectionNode._parentIniSectionNode._name); iniSectionNode = iniSectionNode._parentIniSectionNode; } return(name.ToString()); }
public ChoIniSectionNode GetSection(string sectionName) { foreach (ChoIniNode iniNode in _iniNodes) { if (iniNode is ChoIniSectionNode) { if (String.Compare(((ChoIniSectionNode)iniNode).Name, sectionName, false) == 0) { return(iniNode as ChoIniSectionNode); } } else if (iniNode is ChoIniIncludeFileNode) { ChoIniSectionNode sectionNode = ((ChoIniIncludeFileNode)iniNode).GetSection(sectionName); if (sectionNode != null) { return(sectionNode); } } } return(null); }
public bool TryGetSection(string sectionName, out ChoIniSectionNode section) { section = GetSection(sectionName); return(section != null); }
internal void UncommentSection(ChoIniSectionNode section) { section.Uncomment(); }
internal bool CommentSection(ChoIniSectionNode section) { return(section.Comment()); }
internal bool DeleteSection(ChoIniSectionNode section) { return(Remove(section)); }
public bool TryGetSection(string sectionName, out ChoIniSectionNode section) { return(_iniDocument.TryGetSection(sectionName, out section)); }