NameValueSectionHandler.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // System.Configuration.NameValueSectionHandler.cs
  3. //
  4. // Author:
  5. // Christopher Podurgiel ([email protected])
  6. //
  7. // (C) Chris Podurgiel
  8. //
  9. using System;
  10. using System.Xml;
  11. using System.Collections.Specialized;
  12. namespace System.Configuration
  13. {
  14. /// <summary>
  15. /// Summary description for NameValueSectionHandler.
  16. /// </summary>
  17. public class NameValueSectionHandler : IConfigurationSectionHandler
  18. {
  19. /// <summary>
  20. /// Creates a new configuration handler and adds the specified configuration object to the collection.
  21. /// </summary>
  22. /// <param name="parent">Composed from the configuration settings in a corresponding parent configuration section.</param>
  23. /// <param name="context">Provides access to the virtual path for which the configuration section handler computes configuration values. Normally this parameter is reserved and is null.</param>
  24. /// <param name="section">The XML node that contains the configuration information to be handled. section provides direct access to the XML contents of the configuration section.</param>
  25. /// <returns></returns>
  26. public object Create(object parent, object context, XmlNode section)
  27. {
  28. return ConfigHelper.GetNameValueCollection (parent as NameValueCollection, section,
  29. KeyAttributeName, ValueAttributeName);
  30. }
  31. /// <summary>
  32. /// Gets the name of the key attribute tag. This property is overidden by derived classes to change
  33. /// the name of the key attribute tag. The default is "key".
  34. /// </summary>
  35. protected virtual string KeyAttributeName
  36. {
  37. get {
  38. return "key";
  39. }
  40. }
  41. /// <summary>
  42. /// Gets the name of the value tag. This property may be overidden by derived classes to change
  43. /// the name of the value tag. The default is "value".
  44. /// </summary>
  45. protected virtual string ValueAttributeName
  46. {
  47. get {
  48. return "value";
  49. }
  50. }
  51. }
  52. }