/// <summary> /// Creates an XML string containing an unmerged view of the <see cref="T:System.Configuration.ConfigurationSection"/> object as a single section to write to a file. /// </summary> /// <returns> /// An XML string containing an unmerged view of the <see cref="T:System.Configuration.ConfigurationSection"/> object. /// </returns> /// <param name="parentElement">The <see cref="T:System.Configuration.ConfigurationElement"/> instance to use as the parent when performing the un-merge.</param> /// <param name="name">The name of the section to create.</param> /// <param name="saveMode">The <see cref="T:System.Configuration.ConfigurationSaveMode"/> instance to use when writing to a string.</param> protected override string SerializeSection(ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode) { ExtensionElementMap.Clear(); currentSection = this; TypeResolver.SetAliases(this); this.InitializeSectionExtensions(); var sb = new StringBuilder(); using (var writer = MakeXmlWriter(sb)) { writer.WriteStartElement(name, XmlNamespace); writer.WriteAttributeString("xmlns", XmlNamespace); this.TypeAliases.SerializeElementContents(writer, "alias"); this.Namespaces.SerializeElementContents(writer, "namespace"); this.Assemblies.SerializeElementContents(writer, "assembly"); this.SectionExtensions.SerializeElementContents(writer, "sectionExtension"); this.Containers.SerializeElementContents(writer, "container"); writer.WriteEndElement(); } return(sb.ToString()); }
/// <summary> /// Reads XML from the configuration file. /// </summary> /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> object, which reads from the configuration file. </param> /// <exception cref="T:System.Configuration.ConfigurationErrorsException"><paramref name="reader"/> found no elements in the configuration file.</exception> protected override void DeserializeSection(XmlReader reader) { ExtensionElementMap.Clear(); currentSection = this; base.DeserializeSection(reader); }