PageRenderTime 20ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/BlogEngine/DotNetSlave.BusinessLogic/Providers/BlogProviderCollection.cs

#
C# | 52 lines | 31 code | 8 blank | 13 comment | 3 complexity | 7b0de53d9ee6e0346dc17c19efb7109c MD5 | raw file
 1namespace BlogEngine.Core.Providers
 2{
 3    using System;
 4    using System.Configuration.Provider;
 5
 6    /// <summary>
 7    /// A collection of all registered providers.
 8    /// </summary>
 9    public class BlogProviderCollection : ProviderCollection
10    {
11        #region Indexers
12
13        /// <summary>
14        ///     Gets a provider by its name.
15        /// </summary>
16        /// <param name="name">The name of the provider.</param>
17        public new BlogProvider this[string name]
18        {
19            get
20            {
21                return (BlogProvider)base[name];
22            }
23        }
24
25        #endregion
26
27        #region Public Methods
28
29        /// <summary>
30        /// Add a provider to the collection.
31        /// </summary>
32        /// <param name="provider">
33        /// The provider.
34        /// </param>
35        public override void Add(ProviderBase provider)
36        {
37            if (provider == null)
38            {
39                throw new ArgumentNullException("provider");
40            }
41
42            if (!(provider is BlogProvider))
43            {
44                throw new ArgumentException("Invalid provider type", "provider");
45            }
46
47            base.Add(provider);
48        }
49
50        #endregion
51    }
52}