/* * <summary> * Creates a new instance of <see cref="SectionTreeCollection"/> class. * Which is a tree like structure for handling <see cref="SectionData"/> * </summary> * <param name="data"> * <see cref="SectionData" that you want this tree node to store. * </param> */ public SectionTreeCollection(SectionTreeCollection orig, SectionData data) { _nodes = new Dictionary <string, List <SectionTreeCollection> >(); _parent = _root; _data = orig._data; foreach (string sectName in orig._nodes.Keys) { _nodes.Add(sectName, orig._nodes[sectName].Clone()); } }
/* * <summary> * Remove the child <see cref="SectionTreeCollect"/> with the section name * passed as sectionName. * </summary> */ public bool Remove(string sectionName, SectionTreeCollection child) { if (_nodes.ContainsKey(sectionName)) { if (_nodes[sectionName].Contains(child)) { _nodes[sectionName].Remove(child); if (_nodes[sectionName].Count == 0) { _nodes.Remove(sectionName); } return(true); } } return(false); }
/* * <summary> * Add child to the current <see cref="SectionTreeCollection"/> * </summary> */ public void Add(SectionTreeCollection child) { child.Data.Level = this.Level + 1; if (_nodes.ContainsKey(child._data.SectionName)) { _nodes[child._data.SectionName].Add(child); } else { _nodes.Add(child._data.SectionName, new List <SectionTreeCollection>() { child }); } child._parent = this; }
/* * <summary> * Creates a new instance of <see cref="SectionTreeCollection"/> class. * Which is a tree like structure for handling <see cref="SectionData"/> * </summary> * <param name="data"> * <see cref="SectionData" that you want this tree node to store. * </param> */ public SectionTreeCollection(SectionData data) { _data = data; _nodes = new Dictionary <string, List <SectionTreeCollection> >(); _parent = _root; }