ComponentFactory.Krypton.Workspace.KryptonWorkspaceSequence.LoadFromXml C# (CSharp) Method

LoadFromXml() public method

Request this sequence load and recreate children.
public LoadFromXml ( KryptonWorkspace workspace, XmlReader xmlReader, UniqueNameToPage existingPages ) : void
workspace KryptonWorkspace Reference to owning workspace instance.
xmlReader XmlReader Xml reader for loading information.
existingPages UniqueNameToPage Dictionary on existing pages before load.
return void
        public void LoadFromXml(KryptonWorkspace workspace, 
                                XmlReader xmlReader,
                                UniqueNameToPage existingPages)
        {
            // Load the sequence details
            workspace.ReadSequenceElement(xmlReader, this);

            // If the sequence contains nothing then exit immediately
            if (!xmlReader.IsEmptyElement)
            {
                do
                {
                    // Read the next Element
                    if (!xmlReader.Read())
                        throw new ArgumentException("An element was expected but could not be read in.");

                    // Is this the end of the sequence
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                        break;

                    // Is it another sequence?
                    if (xmlReader.Name == "WS")
                    {
                        KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence();
                        sequence.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(sequence);
                    }
                    else if (xmlReader.Name == "WC")
                    {
                        KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                        cell.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(cell);
                    }
                    else
                        throw new ArgumentException("Unknown element was encountered.");
                }
                while (true);
            }
        }

Usage Example

        /// <summary>
        /// Request this sequence load and recreate children.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlReader">Xml reader for loading information.</param>
        /// <param name="existingPages">Dictionary on existing pages before load.</param>
        public void LoadFromXml(KryptonWorkspace workspace,
                                XmlReader xmlReader,
                                UniqueNameToPage existingPages)
        {
            // Load the sequence details
            workspace.ReadSequenceElement(xmlReader, this);

            // If the sequence contains nothing then exit immediately
            if (!xmlReader.IsEmptyElement)
            {
                do
                {
                    // Read the next Element
                    if (!xmlReader.Read())
                    {
                        throw new ArgumentException("An element was expected but could not be read in.");
                    }

                    // Is this the end of the sequence
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    // Is it another sequence?
                    switch (xmlReader.Name)
                    {
                    case "WS":
                        KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence();
                        sequence.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(sequence);
                        break;

                    case "WC":
                        KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                        cell.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(cell);
                        break;

                    default:
                        throw new ArgumentException("Unknown element was encountered.");
                    }
                }while (true);
            }
        }
All Usage Examples Of ComponentFactory.Krypton.Workspace.KryptonWorkspaceSequence::LoadFromXml