Exemplo n.º 1
0
        /// <summary>
        /// Adds the specified node in order of the 'sortOrder' attribute to the children of this node.
        /// </summary>
        /// <param name="xmlChild">The child element to add to the parent element.</param>
        public void InsertBySortOrder(CommonElement xmlChild)
        {
            // Get the attribute used in the sorting.
            string childSortCode = xmlChild.GetAttribute("SortOrder");

            // This does a quick insert sort based on the value of the 'sortOrder' attribute.
            foreach (XmlElement xmlElement in this)
            {
                if (Convert.ToInt32(xmlElement.GetAttribute("SortOrder")) > Convert.ToInt32(childSortCode))
                {
                    this.InsertBefore(xmlChild, xmlElement);
                    return;
                }
            }

            // If the 'sortOrder' attribute is larger than any of the siblings, it goes at the end of the list.
            this.AppendChild(xmlChild);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the specified node in order of the 'name' attribute to the children of this node.
        /// </summary>
        /// <param name="xmlChild">The child element to add to the parent element.</param>
        public void InsertByName(CommonElement xmlChild)
        {
            // Get the attribute used in the sorting.
            string childSortCode = xmlChild.GetAttribute("Name");

            // This does a quick insert sort based on the value of the 'name' attribute.
            foreach (XmlElement xmlElement in this)
            {
                if (String.Compare(xmlElement.GetAttribute("Name"), childSortCode) > 0)
                {
                    this.InsertBefore(xmlChild, xmlElement);
                    return;
                }
            }

            // If the 'name' attribute is larger than any of the siblings, it goes at the end of the list.
            this.AppendChild(xmlChild);
        }