RewriterConfigSerializerSectionHandler.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Configuration;
  3. using System.Xml;
  4. using System.Xml.Serialization;
  5. using System.Xml.XPath;
  6. namespace URLRewriter.Config
  7. {
  8. /// <summary>
  9. /// Deserializes the markup in Web.config into an instance of the <see cref="RewriterConfiguration"/> class.
  10. /// </summary>
  11. public class RewriterConfigSerializerSectionHandler : IConfigurationSectionHandler
  12. {
  13. /// <summary>
  14. /// Creates an instance of the <see cref="RewriterConfiguration"/> class.
  15. /// </summary>
  16. /// <remarks>Uses XML Serialization to deserialize the XML in the Web.config file into an
  17. /// <see cref="RewriterConfiguration"/> instance.</remarks>
  18. /// <returns>An instance of the <see cref="RewriterConfiguration"/> class.</returns>
  19. public object Create(object parent, object configContext, System.Xml.XmlNode section)
  20. {
  21. // Create an instance of XmlSerializer based on the RewriterConfiguration type...
  22. XmlSerializer ser = new XmlSerializer(typeof(RewriterConfiguration));
  23. // Return the Deserialized object from the Web.config XML
  24. return ser.Deserialize(new XmlNodeReader(section));
  25. }
  26. }
  27. }