Ejemplo n.º 1
0
        /// <summary>
        /// This writes the current state or attributes of this object,
        /// in the <c>XML</c> format, to the media or storage accessible by the given writer.
        /// </summary>
        /// <param name="writer">
        /// The <c>XML</c> writer with which the <c>XML</c> format of this object's state
        /// is written.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="reader"/> is <see langword="null"/>.
        /// </exception>
        public override void WriteXml(XmlWriter writer)
        {
            BuildExceptions.NotNull(writer, "writer");

            writer.WriteStartElement(TagName);  // start - TagName
            writer.WriteAttributeString("type", _engineType.ToString());
            writer.WriteAttributeString("name", _engineName);

            // 1. Write the general properties...
            this.OnWriteXml(writer);

            // 2. Write the user properties...
            if (_properties != null)
            {
                _properties.WriteXml(writer);
            }

            // 3. Write the configuration contents...
            writer.WriteStartElement("contents");  // start - contents
            if (_sharedContent != null)
            {
                writer.WriteStartElement("content");
                writer.WriteAttributeString("type", "Shared");
                _sharedContent.WriteXml(writer);
                writer.WriteEndElement();
            }
            if (_includeContent != null)
            {
                writer.WriteStartElement("content");
                writer.WriteAttributeString("type", "Include");
                _includeContent.WriteXml(writer);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();              // end - contents

            // 4. Write the default/system plugin configurations...
            writer.WriteComment(" Options for the default configurations ");
            writer.WriteStartElement("configurations"); // start - configurations
            writer.WriteAttributeString("type", "System");
            if (_configurations != null && _configurations.Count != 0)
            {
                for (int i = 0; i < _configurations.Count; i++)
                {
                    _configurations[i].WriteXml(writer);
                }
            }
            writer.WriteEndElement();                   // end - configurations

            writer.WriteComment(" Options for the plugin configurations ");
            writer.WriteStartElement("configurations"); // start - configurations
            writer.WriteAttributeString("type", "Plugin");
            if (_pluginConfigurations != null && _pluginConfigurations.Count != 0)
            {
                for (int i = 0; i < _pluginConfigurations.Count; i++)
                {
                    _pluginConfigurations[i].WriteXml(writer);
                }
            }
            writer.WriteEndElement();                   // end - configurations

            // 5.  Write the default/system component configurations...
            writer.WriteComment(" Options for the default component configurations ");
            writer.WriteStartElement("componentConfigurations"); // start - componentConfigurations
            writer.WriteAttributeString("type", "System");
            if (_componentConfigurations != null && _componentConfigurations.Count != 0)
            {
                for (int i = 0; i < _componentConfigurations.Count; i++)
                {
                    _componentConfigurations[i].WriteXml(writer);
                }
            }
            writer.WriteEndElement();                            // end - componentConfigurations

            writer.WriteComment(" Options for the plugin component configurations ");
            writer.WriteStartElement("componentConfigurations"); // start - componentConfigurations
            writer.WriteAttributeString("type", "Plugin");
            if (_pluginComponentConfigurations != null && _pluginComponentConfigurations.Count != 0)
            {
                for (int i = 0; i < _pluginComponentConfigurations.Count; i++)
                {
                    _pluginComponentConfigurations[i].WriteXml(writer);
                }
            }
            writer.WriteEndElement();                   // end - componentConfigurations

            writer.WriteEndElement();                   // end - TagName
        }