The Labs \ Source Viewer \ SSCLI \ System.Configuration \ NameValueConfigurationElement

  1. //------------------------------------------------------------------------------
  2. // <copyright file="NameValueConfigurationElement.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. /*
  16. * ImmutableCollections
  17. *
  18. * Copyright (c) 2004 Microsoft Corporation
  19. */
  20. using System;
  21. using System.Collections;
  22. using System.Collections.Specialized;
  23. using System.Net;
  24. using System.Configuration;
  25. //
  26. // This file contains configuration collections that are used by multiple sections
  27. //
  28. namespace System.Configuration
  29. {
  30.    
  31.     public sealed class NameValueConfigurationElement : ConfigurationElement
  32.     {
  33.         private static ConfigurationPropertyCollection _properties;
  34.         private static readonly ConfigurationProperty _propName = new ConfigurationProperty("name", typeof(string), String.Empty, ConfigurationPropertyOptions.IsKey);
  35.         private static readonly ConfigurationProperty _propValue = new ConfigurationProperty("value", typeof(string), String.Empty, ConfigurationPropertyOptions.None);
  36.        
  37.         static NameValueConfigurationElement()
  38.         {
  39.             // Property initialization
  40.             _properties = new ConfigurationPropertyCollection();
  41.             _properties.Add(_propName);
  42.             _properties.Add(_propValue);
  43.         }
  44.        
  45.         protected internal override ConfigurationPropertyCollection Properties {
  46.             get { return _properties; }
  47.         }
  48.        
  49.         //
  50.         // Constructor
  51.         //
  52.         internal NameValueConfigurationElement()
  53.         {
  54.         }
  55.        
  56.         public NameValueConfigurationElement(string name, string value)
  57.         {
  58.             base[_propName] = name;
  59.             base[_propValue] = value;
  60.         }
  61.        
  62.         //
  63.         // Properties
  64.         //
  65.        
  66.         //
  67.         // ConfigurationPropertyOptions.IsKey="true"
  68.         //
  69.         [ConfigurationProperty("name", IsKey = true, DefaultValue = "")]
  70.         public string Name {
  71.             get { return (string)base[_propName]; }
  72.         }
  73.        
  74.         [ConfigurationProperty("value", DefaultValue = "")]
  75.         public string Value {
  76.             get { return (string)base[_propValue]; }
  77.             set { base[_propValue] = value; }
  78.         }
  79.     }
  80. }

Developer Fusion