ComponentFactory.Krypton.Docking.DockingElement.LoadElementFromXml C# (CSharp) Method

LoadElementFromXml() public method

Loads docking configuration information using a provider xml reader.
public LoadElementFromXml ( XmlReader xmlReader, KryptonPageCollection pages ) : void
xmlReader XmlReader Xml reader object.
pages KryptonPageCollection Collection of available pages for adding.
return void
        public virtual void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages)
        {
            // Is it the expected xml element name?
            if (xmlReader.Name != XmlElementName)
                throw new ArgumentException("Element name '" + XmlElementName + "' was expected but found '" + xmlReader.Name + "' instead.");

            // Grab the element attributes
            string elementName = xmlReader.GetAttribute("N");
            string elementCount = xmlReader.GetAttribute("C");

            // Check the name matches up
            if (elementName != Name)
                throw new ArgumentException("Attribute 'N' value '" + Name + "' was expected but found '" + elementName + "' instead.");

            // Let derived class perform element specific persistence
            LoadDockingElement(xmlReader, pages);

            // If there are children then move over them
            int count = int.Parse(elementCount);
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    // Read to the next element
                    if (!xmlReader.Read())
                        throw new ArgumentException("An element was expected but could not be read in.");

                    // Find a child docking element with the matching name
                    IDockingElement child = this[xmlReader.GetAttribute("N")];

                    // Let derived class perform child element specific processing
                    LoadChildDockingElement(xmlReader, pages, child);
                }
            }

            // Read past this element to the end element
            if (!xmlReader.Read())
                throw new ArgumentException("An element was expected but could not be read in.");
        }