/// <summary> /// Add parent information. /// </summary> /// <param name="parentTaxonTreeNode">Parent taxon tree node.</param> /// <param name="parentTaxonRelation">Parent taxon tree relation.</param> public void AddParent(TaxonTreeNode parentTaxonTreeNode, WebTaxonRelation parentTaxonRelation) { Int32 parentIndex; if (Parents.IsEmpty() || Parents[Parents.Count - 1].SortOrder <= parentTaxonTreeNode.SortOrder) { // Insert at the end of the lists. if (Parents.IsNull()) { ParentRelations = new List <WebTaxonRelation>(); Parents = new List <TaxonTreeNode>(); } ParentRelations.Add(parentTaxonRelation); Parents.Add(parentTaxonTreeNode); } else { // Insert into the list. for (parentIndex = 0; parentIndex < Parents.Count; parentIndex++) { if (parentTaxonTreeNode.SortOrder < Parents[parentIndex].SortOrder) { ParentRelations.Insert(parentIndex, parentTaxonRelation); Parents.Insert(parentIndex, parentTaxonTreeNode); break; } } } }
/// <summary> /// Add child information. /// </summary> /// <param name="childTaxonTreeNode">Child taxon tree node.</param> /// <param name="childTaxonRelation">Child taxon relation.</param> public void AddChild(TaxonTreeNode childTaxonTreeNode, WebTaxonRelation childTaxonRelation) { Int32 childIndex; if (Children.IsEmpty() || Children[Children.Count - 1].SortOrder <= childTaxonTreeNode.SortOrder) { // Insert at the end of the lists. if (Children.IsNull()) { ChildRelations = new List <WebTaxonRelation>(); Children = new List <TaxonTreeNode>(); } ChildRelations.Add(childTaxonRelation); Children.Add(childTaxonTreeNode); } else { // Insert into the list. for (childIndex = 0; childIndex < Children.Count; childIndex++) { if (childTaxonTreeNode.SortOrder < Children[childIndex].SortOrder) { ChildRelations.Insert(childIndex, childTaxonRelation); Children.Insert(childIndex, childTaxonTreeNode); break; } } } }