The Labs \ Source Viewer \ SSCLI \ System.Configuration.Provider \ ProviderBase

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ProviderBase.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.Provider
  16. {
  17.     using System.Collections.Specialized;
  18.     using System.Runtime.Serialization;
  19.    
  20.     public abstract class ProviderBase
  21.     {
  22.        
  23.         private string _name;
  24.         private string _Description;
  25.        
  26.         public virtual string Name {
  27.             get { return _name; }
  28.         }
  29.         public virtual string Description {
  30.             get { return string.IsNullOrEmpty(_Description) ? Name : _Description; }
  31.         }
  32.        
  33.         public virtual void Initialize(string name, NameValueCollection config)
  34.         {
  35.             lock (this) {
  36.                 if (_Initialized)
  37.                     throw new InvalidOperationException(SR.GetString(SR.Provider_Already_Initialized));
  38.                 _Initialized = true;
  39.             }
  40.             if (name == null)
  41.                 throw new ArgumentNullException("name");
  42.             if (name.Length == 0)
  43.                 throw new ArgumentException(SR.GetString(SR.Config_provider_name_null_or_empty), "name");
  44.             _name = name;
  45.             if (config != null) {
  46.                 _Description = config["description"];
  47.                 config.Remove("description");
  48.             }
  49.         }
  50.         private bool _Initialized;
  51.     }
  52. }

Developer Fusion