예제 #1
0
 /// <summary>
 /// Overridden to automatically aquire a reference to
 /// root application context to use for DI.
 /// </summary>
 protected override ControlCollection CreateControlCollection()
 {
     // set root application context to signal, that we care
     // for our children ourselves
     if (_suppressDependencyInjection)
     {
         _defaultApplicationContext = WebApplicationContext.GetRootContext();
         return(base.CreateControlCollection());
     }
     else
     {
         return(new InitRecursiveInterceptingControlsCollection(this));
     }
 }
        ///<summary>
        ///Initializes the provider.
        ///</summary>
        ///
        ///<param name="config">A collection of the name/value pairs representing the provider-specific
        /// attributes specified in the configuration for this provider.
        /// The <c>providerId</c> attribute may be used to override the name being used for looking up an object definition.
        /// </param>
        ///<param name="name">The friendly name of the provider.</param>
        ///<exception cref="T:System.ArgumentNullException">The <paramref name="name"/> or <paramref name="config"/> is null.</exception>
        ///<exception cref="T:System.InvalidOperationException">An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider has already been initialized.</exception>
        ///<exception cref="T:System.ArgumentException">The <paramref name="name"/> has a length of zero or providerId attribute is not set.</exception>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            string providerId = config["providerId"];

            if (String.IsNullOrEmpty(providerId))
            {
                providerId = name;
            }
            config.Remove("providerId");

            this.wrappedProvider = (System.Web.SiteMapProvider)WebApplicationContext.GetRootContext().GetObject(providerId);
            this.wrappedProvider.Initialize(name, config);
        }