DictionarySectionHandler.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // Permission is hereby granted, free of charge, to any person obtaining
  3. // a copy of this software and associated documentation files (the
  4. // "Software"), to deal in the Software without restriction, including
  5. // without limitation the rights to use, copy, modify, merge, publish,
  6. // distribute, sublicense, and/or sell copies of the Software, and to
  7. // permit persons to whom the Software is furnished to do so, subject to
  8. // the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be
  11. // included in all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  17. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  18. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  19. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. //
  21. //
  22. // System.Configuration.DictionarySectionHandler.cs
  23. //
  24. // Author:
  25. // Christopher Podurgiel ([email protected])
  26. //
  27. // (C) Chris Podurgiel
  28. //
  29. using System;
  30. using System.Collections;
  31. using System.Collections.Specialized;
  32. #if (XML_DEP)
  33. using System.Xml;
  34. #else
  35. using XmlNode = System.Object;
  36. #endif
  37. namespace System.Configuration
  38. {
  39. /// <summary>
  40. /// Summary description for DictionarySectionHandler.
  41. /// </summary>
  42. public class DictionarySectionHandler : IConfigurationSectionHandler
  43. {
  44. /// <summary>
  45. /// Creates a new DictionarySectionHandler object and adds the object to the collection.
  46. /// </summary>
  47. /// <param name="parent">Composed from the configuration settings in a corresponding parent configuration section.</param>
  48. /// <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>
  49. /// <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>
  50. /// <returns></returns>
  51. public virtual object Create(object parent, object context, XmlNode section)
  52. {
  53. #if (XML_DEP)
  54. return ConfigHelper.GetDictionary (parent as IDictionary, section,
  55. KeyAttributeName, ValueAttributeName);
  56. #else
  57. return null;
  58. #endif
  59. }
  60. /// <summary>
  61. /// Gets the name of the key attribute tag. This property is overidden by derived classes to change
  62. /// the name of the key attribute tag. The default is "key".
  63. /// </summary>
  64. protected virtual string KeyAttributeName
  65. {
  66. get {
  67. return "key";
  68. }
  69. }
  70. /// <summary>
  71. /// Gets the name of the value tag. This property may be overidden by derived classes to change
  72. /// the name of the value tag. The default is "value".
  73. /// </summary>
  74. protected virtual string ValueAttributeName
  75. {
  76. get {
  77. return "value";
  78. }
  79. }
  80. }
  81. }