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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ProviderSettingsCollection.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. namespace System.Configuration
  16. {
  17.     using System;
  18.     using System.Xml;
  19.     using System.Configuration;
  20.     using System.Collections.Specialized;
  21.     using System.Collections;
  22.     using System.IO;
  23.     using System.Text;
  24.     using System.Globalization;
  25.    
  26.     [ConfigurationCollection(typeof(ProviderSettings))]
  27.     public sealed class ProviderSettingsCollection : ConfigurationElementCollection
  28.     {
  29.         private static ConfigurationPropertyCollection _properties;
  30.        
  31.         static ProviderSettingsCollection()
  32.         {
  33.             // Property initialization
  34.             _properties = new ConfigurationPropertyCollection();
  35.         }
  36.        
  37.         public ProviderSettingsCollection() : base(StringComparer.OrdinalIgnoreCase)
  38.         {
  39.         }
  40.        
  41.         protected internal override ConfigurationPropertyCollection Properties {
  42.             get { return _properties; }
  43.         }
  44.        
  45.         public void Add(ProviderSettings provider)
  46.         {
  47.             if (provider != null) {
  48.                 provider.UpdatePropertyCollection();
  49.                 BaseAdd(provider);
  50.             }
  51.         }
  52.        
  53.         public void Remove(string name)
  54.         {
  55.             BaseRemove(name);
  56.         }
  57.        
  58.         public void Clear()
  59.         {
  60.             BaseClear();
  61.         }
  62.        
  63.         protected override ConfigurationElement CreateNewElement()
  64.         {
  65.             return new ProviderSettings();
  66.         }
  67.         protected override object GetElementKey(ConfigurationElement element)
  68.         {
  69.             return ((ProviderSettings)element).Name;
  70.         }
  71.        
  72.         public new ProviderSettings this[string key]
  73.         {
  74.             get { return (ProviderSettings)BaseGet(key); }
  75.         }
  76.        
  77.         public ProviderSettings this[int index]
  78.         {
  79.             get { return (ProviderSettings)BaseGet(index); }
  80.             set {
  81.                 if (BaseGet(index) != null)
  82.                     BaseRemoveAt(index);
  83.                
  84.                 BaseAdd(index, value);
  85.             }
  86.         }
  87.     }
  88. }

Developer Fusion