DictionarySectionHandler.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #endif
  35. namespace System.Configuration
  36. {
  37. /// <summary>
  38. /// Summary description for DictionarySectionHandler.
  39. /// </summary>
  40. public class DictionarySectionHandler : IConfigurationSectionHandler
  41. {
  42. #if (XML_DEP)
  43. /// <summary>
  44. /// Creates a new DictionarySectionHandler object and adds the object to the collection.
  45. /// </summary>
  46. /// <param name="parent">Composed from the configuration settings in a corresponding parent configuration section.</param>
  47. /// <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>
  48. /// <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>
  49. /// <returns></returns>
  50. public virtual object Create(object parent, object context, XmlNode section)
  51. {
  52. return ConfigHelper.GetDictionary (parent as IDictionary, section,
  53. KeyAttributeName, ValueAttributeName);
  54. }
  55. #endif
  56. /// <summary>
  57. /// Gets the name of the key attribute tag. This property is overidden by derived classes to change
  58. /// the name of the key attribute tag. The default is "key".
  59. /// </summary>
  60. protected virtual string KeyAttributeName
  61. {
  62. get {
  63. return "key";
  64. }
  65. }
  66. /// <summary>
  67. /// Gets the name of the value tag. This property may be overidden by derived classes to change
  68. /// the name of the value tag. The default is "value".
  69. /// </summary>
  70. protected virtual string ValueAttributeName
  71. {
  72. get {
  73. return "value";
  74. }
  75. }
  76. }
  77. }