Beispiel #1
0
        /// <summary>
        /// Reads the configuration related to the set of configured
        /// providers and sets the default and collection of providers and settings.
        /// </summary>
        private static void Initialize()
        {
            MessageProviderConfiguration configSection = (MessageProviderConfiguration)ConfigurationManager.GetSection("MessageProviders");

            if (configSection == null)
            {
                throw new ConfigurationErrorsException("Data provider section is not set.");
            }

            _providerCollection = new MessageProviderCollection();
            ProvidersHelper.InstantiateProviders(configSection.Providers, _providerCollection, typeof(MessageProviderBase));

            _providerSettings = configSection.Providers;

            if (_providerCollection.Count > 0)
            {
                if (_providerCollection[configSection.DefaultProviderName] == null)
                {
                    throw new ConfigurationErrorsException("Default data provider is not set.");
                }
                _default = _providerCollection[configSection.DefaultProviderName];
                var defaultSettings = _providerSettings[configSection.DefaultProviderName];

                _default.SetParameters(defaultSettings.Parameters);
            }
        }
        /// <summary>
        /// Reads the configuration related to the set of configured
        /// providers and sets the default and collection of providers and settings.
        /// </summary>
        public static void Initialize()
        {
            CacheProviderConfiguration configSection = (CacheProviderConfiguration)ConfigurationManager.GetSection("CacheProviders");

            if (configSection == null)
#pragma warning disable CS0618 // Type or member is obsolete
            {
                throw new ConfigurationException("Data provider section is not set.");
            }
#pragma warning restore CS0618 // Type or member is obsolete

            _providerCollection = new CacheProviderCollection();
            ProvidersHelper.InstantiateProviders(configSection.Providers, _providerCollection, typeof(CacheProviderBase));

            _providerSettings = configSection.Providers;

            if (_providerCollection[configSection.DefaultProviderName] == null)
#pragma warning disable CS0618 // Type or member is obsolete
            {
                throw new ConfigurationException("Default data provider is not set.");
            }
#pragma warning restore CS0618 // Type or member is obsolete

            _default = _providerCollection[configSection.DefaultProviderName];

            var defaultSettings = _providerSettings[configSection.DefaultProviderName];

            _default.SetParameters(defaultSettings.Parameters);
        }
Beispiel #3
0
        private void LoadDefaultFileRegConfig(ClientDependencySection section)
        {
            if (section.FileRegistrationElement.Providers.Count == 0)
            {
                //create new providers
                var php = new PageHeaderProvider();
                php.Initialize(PageHeaderProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(php);

                var csrp = new LazyLoadProvider();
                csrp.Initialize(LazyLoadProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(csrp);

                var lcp = new LoaderControlProvider();
                lcp.Initialize(LoaderControlProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(lcp);

                var plhp = new PlaceHolderProvider();
                plhp.Initialize(PlaceHolderProvider.DefaultName, null);
                FileRegistrationProviderCollection.Add(plhp);
            }
            else
            {
                ProvidersHelper.InstantiateProviders(section.FileRegistrationElement.Providers, FileRegistrationProviderCollection, typeof(BaseFileRegistrationProvider));
            }
        }
Beispiel #4
0
        private static void Initialize()
        {
            try
            {
                MessageProviderConfigurationSection messageConfig = null;

                if (!m_isInitialized)
                {
                    // 找到配置文件中“MessageProvider”节点
                    messageConfig = (MessageProviderConfigurationSection)ConfigurationManager.GetSection("MessageProvider");

                    if (messageConfig == null)
                    {
                        throw new ConfigurationErrorsException("在配置文件中没找到“MessageProvider”节点");
                    }

                    _providers = new MessageProviderCollection();

                    // 使用System.Web.Configuration.ProvidersHelper类调用每个Provider的Initialize()方法
                    ProvidersHelper.InstantiateProviders(messageConfig.Providers, _providers, typeof(MessageProvider));

                    // 所用的Provider为配置中默认的Provider
                    _provider = _providers[messageConfig.DefaultProvider] as MessageProvider;

                    m_isInitialized = true;
                }
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                throw new Exception(msg);
            }
        }
Beispiel #5
0
        private static void LoadProvider()
        {
            // if we do not have initiated the provider
            if (_provider == null)
            {
                lock (_lock)
                {
                    // Do this again to make sure _provider is still null
                    if (_provider == null)
                    {
                        // Get a reference to the <requestService> section
                        ChatServiceSection section = (ChatServiceSection)WebConfigurationManager.GetSection("LCSK/chatService");

                        // Load the default provider
                        if (section.Providers.Count > 0 && !string.IsNullOrEmpty(section.DefaultProvider) && section.Providers[section.DefaultProvider] != null)
                        {
                            _provider = (ChatProvider)ProvidersHelper.InstantiateProvider(section.Providers[section.DefaultProvider], typeof(ChatProvider));
                        }

                        if (_provider == null)
                        {
                            throw new ProviderException("Unable to load the ChatProvider");
                        }
                    }
                }
            }
        }
Beispiel #6
0
        private static void LoadProviders()
        {
            // Avoid claiming lock if providers are already loaded
            if (_defaultProvider == null)
            {
                lock (_lock)
                {
                    // Do this again to make sure _defaultProvider is still null
                    if (_defaultProvider == null)
                    {
                        ServicesSection section = (ServicesSection)
                                                  WebConfigurationManager.GetSection("servicesProvider");

                        _providers = new ServicesProviderCollection();

                        ProvidersHelper.InstantiateProviders(
                            section.Providers, _providers,
                            typeof(ServicesProvider));

                        _defaultProvider = _providers[section.DefaultProvider];

                        if (_defaultProvider == null)
                        {
                            throw new ProviderException
                                      ("Unable to load default ServiceHostProvider");
                        }
                    }
                }
            }
        }
Beispiel #7
0
        public static void LoadProviders()
        {
            if (_provider == null)
            {
                lock (_lock)
                {
                    if (_provider == null)
                    {
                        // Get a reference to the <acdService> section
                        ACDServiceSection section = (ACDServiceSection)
                                                    WebConfigurationManager.GetSection
                                                        ("acdService");

                        // Load registered providers and point _provider
                        // to the default provider
                        _providers = new ACDProviderCollection();
                        ProvidersHelper.InstantiateProviders
                            (section.Providers, _providers,
                            typeof(ACDProvider));
                        _provider = _providers[section.DefaultProvider];

                        if (_provider == null)
                        {
                            throw new ProviderException
                                      ("Unable to load default ACDProvider");
                        }
                    }
                }
            }
        }
Beispiel #8
0
        private static void Initialize()
        {
            try
            {
                //Get the feature's configuration info
                StockProviderConfiguration qc =
                    (StockProviderConfiguration)ConfigurationManager.GetSection("stockProvider");

                if (qc.DefaultProvider == null || qc.Providers == null || qc.Providers.Count < 1)
                {
                    throw new ProviderException("You must specify a valid default provider.");
                }

                //Instantiate the providers
                providerCollection = new StockProviderCollection();
                ProvidersHelper.InstantiateProviders(qc.Providers, providerCollection, typeof(StockProvider));
                providerCollection.SetReadOnly();
                defaultProvider = providerCollection[qc.DefaultProvider];
                if (defaultProvider == null)
                {
                    throw new ConfigurationErrorsException(
                              "You must specify a default provider for the feature.",
                              qc.ElementInformation.Properties["defaultProvider"].Source,
                              qc.ElementInformation.Properties["defaultProvider"].LineNumber);
                }
            }
            catch (Exception ex)
            {
                initializationException = ex;
                isInitialized           = true;
                throw ex;
            }

            isInitialized = true; //error-free initialization
        }
Beispiel #9
0
        private static void InitializeProvider()
        {
            if (_provider != null)
            {
                return;
            }

            var section = ConfigurationManager.GetSection("oauth") as OAuthSection;

            // if there is no oauth section, then don't use this module
            if (section == null)
            {
                return;
            }

            var providers = new OAuthProviderCollection();

            ProvidersHelper.InstantiateProviders(section.Providers, providers, typeof(OAuthProviderBase));

            if ((section.DefaultProvider == null) || (providers.Count < 1))
            {
                ThrowConfigurationError(section, "Default OAuth Provider must be specified.");
            }

            _provider = providers[section.DefaultProvider];
            if (_provider == null)
            {
                ThrowConfigurationError(section, "Default OAuth Provider could not be found.");
            }
        }
Beispiel #10
0
 private static void Initialize()
 {
     if (!_initialized)
     {
         lock (_lock)
         {
             if (!_initialized)
             {
                 try
                 {
                     CommerceSection section = ConfigurationManager.GetSection("lionsguard/commerce") as CommerceSection;
                     if (section != null)
                     {
                         _providers = new CommerceProviderCollection();
                         ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof(CommerceProvider));
                         _provider = _providers[section.DefaultProvider];
                         if (_provider == null)
                         {
                             throw new ConfigurationErrorsException("Default CommerceProvider not found in application configuration file.", section.ElementInformation.Properties["defaultProvider"].Source, section.ElementInformation.Properties["defaultProvider"].LineNumber);
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     _initException = ex;
                 }
                 _initialized = true;
             }
         }
     }
     if (_initException != null)
     {
         throw _initException;
     }
 }
Beispiel #11
0
        /// <summary>
        /// This function loads providers from the App.Config or Web.config file
        /// </summary>
        private static void LoadProvider()
        {
            // Avoid claiming lock if provider already loaded
            if (_objProvider == null)
            {
                lock (_lock)
                {
                    //make sure _provider is still null
                    if (_objProvider == null)
                    {
                        //Get a reference to the <cacheProvider> section
                        CacheProviderSection objSection = (CacheProviderSection)
                                                          WebConfigurationManager.GetSection("cacheProvider");

                        //Load registered providers and point _objProvider to the default provider
                        _objProviders = new CacheProviderCollection();
                        ProvidersHelper.InstantiateProviders
                            (objSection.Providers, _objProviders, typeof(CacheProvider));
                        _objProvider = _objProviders[objSection.DefaultProvider];

                        if (_objProvider == null)
                        {
                            throw new ProviderException("Unable to load default cache provider");
                        }
                    }
                }
            }
        }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DdlProviders.Items.Clear();

                BlogProviderSection    section   = (BlogProviderSection)WebConfigurationManager.GetSection("BlogEngine/blogProvider");
                BlogProviderCollection providers = new BlogProviderCollection();
                ProvidersHelper.InstantiateProviders(section.Providers, providers, typeof(BlogProvider));
                List <Blog> blogs = BlogService.Provider.FillBlogs();

                foreach (Blog blog in blogs)
                {
                    DdlBlogs.Items.Add(new ListItem(blog.Name, blog.Id.ToString()));
                }

                foreach (BlogProvider provider in providers)
                {
                    // Don't add the current provider in use, that would be messy.
                    if (provider.Name != section.DefaultProvider)
                    {
                        DdlProviders.Items.Add(provider.Name);
                    }
                }
            }
        }
Beispiel #13
0
        private static void InitializeSettings(RoleManagerSection settings)
        {
            if (!s_Initialized)
            {
                s_Providers = new RoleProviderCollection();

                if (HostingEnvironment.IsHosted)
                {
                    ProvidersHelper.InstantiateProviders(settings.Providers, s_Providers, typeof(RoleProvider));
                }
                else
                {
                    foreach (ProviderSettings ps in settings.Providers)
                    {
                        Type t = Type.GetType(ps.Type, true, true);
                        if (!typeof(RoleProvider).IsAssignableFrom(t))
                        {
                            throw new ArgumentException(SR.GetString(SR.Provider_must_implement_type, typeof(RoleProvider).ToString()));
                        }
                        RoleProvider        provider    = (RoleProvider)Activator.CreateInstance(t);
                        NameValueCollection pars        = ps.Parameters;
                        NameValueCollection cloneParams = new NameValueCollection(pars.Count, StringComparer.Ordinal);
                        foreach (string key in pars)
                        {
                            cloneParams[key] = pars[key];
                        }
                        provider.Initialize(ps.Name, cloneParams);
                        s_Providers.Add(provider);
                    }
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private static void Initialize()
        {
            var configuration = (DataProviderConfiguration)ConfigurationManager.GetSection("DataProvider");

            if (configuration == null || configuration.DefaultProvider == null || configuration.Providers == null || configuration.Providers.Count < 1)
            {
                throw new ProviderException("You must specify a valid default data provider.");
            }

            Providers = new DataProviderCollection();
            ProvidersHelper.InstantiateProviders(configuration.Providers, Providers, typeof(DataProvider));
            Providers.SetReadOnly();
            Provider = Providers[configuration.DefaultProvider];

            if (Provider == null)
            {
                var propertyInformation = configuration.ElementInformation.Properties["defaultProvider"];

                if (propertyInformation != null)
                {
                    throw new ConfigurationErrorsException(
                              "You must specify a default provider for the feature.",
                              propertyInformation.Source,
                              propertyInformation.LineNumber);
                }
            }
        }
        /// <summary>
        /// Instantiates all configured providers.
        /// </summary>
        public void InstantiateProviders(string configSectionName)
        {
            _configSectionName = configSectionName;
            if (LogProvider != null)
            {
                LogProvider.Debug("Initializing " + (_configSectionName ?? ""));
            }
            try
            {
                _config = ConfigurationManager.GetSection(_configSectionName) as ProviderConfigurationSection;
                if (_config == null)
                {
                    throw new ProviderException(string.Format("'{0}' section missing.", _configSectionName));
                }
                if (_config.Providers == null || _config.Providers.Count == 0)
                {
                    throw new ProviderException(string.Format("No '{0}' providers have been configured.", _configSectionName));
                }

                ProvidersHelper.InstantiateProviders(_config.Providers, this, typeof(T));

                SetActiveProvider(_config.DefaultProvider);
            }
            catch (Exception ex)
            {
                if (LogProvider != null)
                {
                    LogProvider.Fatal("Could not Instantiate providers from configuration.", ex);
                }
                throw;
            }
        }
Beispiel #16
0
        private static void InitializeService()
        {
            if (OAuthServiceBase.Instance != null)
            {
                return;
            }

            var section = ConfigurationManager.GetSection("oauth") as OAuthSection;

            // if there is no oauth section, then don't use this module
            if (section == null)
            {
                return;
            }

            var services = new OAuthServiceCollection();

            ProvidersHelper.InstantiateProviders(section.Services, services, typeof(OAuthServiceBase));

            if ((section.DefaultProvider == null) || (services.Count < 1))
            {
                ThrowConfigurationError(section, "Default OAuth Service must be specified.");
            }

            OAuthServiceBase.Instance = services[section.DefaultService];
            if (_provider == null)
            {
                ThrowConfigurationError(section, "Default OAuth Service could not be found.");
            }
        }
Beispiel #17
0
        /// <summary>
        /// Load the providers from the web.config.
        /// </summary>
        private static void LoadProviders()
        {
            // Avoid claiming lock if providers are already loaded
            if (_provider == null)
            {
                lock (TheLock)
                {
                    // Do this again to make sure _provider is still null
                    if (_provider == null)
                    {
                        // Get a reference to the <blogProvider> section
                        var section = (BlogProviderSection)WebConfigurationManager.GetSection("BlogEngine/blogProvider");

                        // Load registered providers and point _provider
                        // to the default provider
                        _providers = new BlogProviderCollection();
                        ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof(BlogProvider));
                        _provider = _providers[section.DefaultProvider];

                        if (_provider == null)
                        {
                            throw new ProviderException("Unable to load default BlogProvider");
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// <exception cref="System.Configuration.ConfigurationErrorsException">dataSerializers configuration section is not set correctly.</exception>
        /// <exception cref="System.Exception">_defaultProvider</exception>
        private static void Initialize()
        {
            // Parse config
            var config = (DataSerializersSection)ConfigurationManager.GetSection("karbon/dataSerializers");

            if (config == null)
            {
                throw new ConfigurationErrorsException("dataSerializers configuration section is not set correctly.");
            }

            // Create providers
            _providers = new DataSerializerCollection();

            ProvidersHelper.InstantiateProviders(config.Providers,
                                                 _providers, typeof(DataSerializer));

            _providers.SetReadOnly();

            // Get default provider
            _defaultProvider = _providers[config.Default];

            if (_defaultProvider == null)
            {
                throw new Exception("_defaultProvider");
            }
        }
Beispiel #19
0
        private static void LoadProviders()
        {
            if (_provider == null)
            {
                lock (_lock)
                {
                    // Do this again to make sure _provider is still null
                    if (_provider == null)
                    {
                        ProviderSection section = (ProviderSection)ConfigurationManager.GetSection("MetaBase");

                        if (section == null)
                        {
                            throw new System.Exception(string.Format("Section Not Found : {0}", "MetaBase"));
                        }


                        _providers = new ProviderCollection();

                        ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof(Data.DataProvider));
                        _provider = (Data.DataProvider)_providers[section.DefaultProvider];

                        if (_provider == null)
                        {
                            throw new System.Configuration.Provider.ProviderException("Unable to load Data Provider");
                        }
                    }
                }
            }
        }
Beispiel #20
0
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            base.Initialize(name, config);

            applicationName = GetStringConfigValue(config, "applicationName", "/");
            string connectionStringName = config ["connectionStringName"];

            if (applicationName.Length > 256)
            {
                throw new ProviderException("The ApplicationName attribute must be 256 characters long or less.");
            }
            if (connectionStringName == null || connectionStringName.Length == 0)
            {
                throw new ProviderException("The ConnectionStringName attribute must be present and non-zero length.");
            }

            // XXX check connectionStringName and commandTimeout

            connectionString = WebConfigurationManager.ConnectionStrings [connectionStringName];
            if (connectionString == null)
            {
                throw new ProviderException(String.Format("The connection name '{0}' was not found in the applications configuration or the connection string is empty.", connectionStringName));
            }
            factory = String.IsNullOrEmpty(connectionString.ProviderName) ?
                      System.Data.SqlClient.SqlClientFactory.Instance :
                      ProvidersHelper.GetDbProviderFactory(connectionString.ProviderName);
        }
            /// <summary>
            /// Instantiates the configured providers based on the supplied connection string.
            /// </summary>
            private void LoadProviders()
            {
                DataRepository.LoadProviders();

                // Avoid claiming lock if providers are already loaded
                if (_providers == null)
                {
                    lock ( SyncRoot )
                    {
                        // Do this again to make sure _provider is still null
                        if (_providers == null)
                        {
                            // apply connection information to each provider
                            for (int i = 0; i < NetTiersSection.Providers.Count; i++)
                            {
                                NetTiersSection.Providers[i].Parameters["connectionStringName"] = _connectionStringName;
                                // remove previous connection string, if any
                                NetTiersSection.Providers[i].Parameters.Remove("connectionString");

                                if (!String.IsNullOrEmpty(_connectionString))
                                {
                                    NetTiersSection.Providers[i].Parameters["connectionString"] = _connectionString;
                                }
                            }

                            // Load registered providers and point _provider to the default provider
                            _providers = new NetTiersProviderCollection();

                            ProvidersHelper.InstantiateProviders(NetTiersSection.Providers, _providers, typeof(NetTiersProvider));
                            _provider = _providers[NetTiersSection.DefaultProvider];
                        }
                    }
                }
            }
Beispiel #22
0
        /// <summary>
        /// The load providers.
        /// </summary>
        /// <exception cref="ProviderException">
        /// </exception>
        private static void LoadProviders()
        {
            if (_provider == null)
            {
                lock (Lock)
                {
                    var section = AppConfig.Instance.Images;

                    _providers = new ImageProviderCollection();
                    ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof(ImageProvider));
                    _provider = (ImageProvider)_providers[section.DefaultProvider];

                    _photoResize = new Dictionary <string, ImageResize>();

                    foreach (ImageResizeElement photoResize in section.ImageResizes)
                    {
                        _photoResize.Add(photoResize.Name, new ImageResize(photoResize));
                    }

                    if (_provider == null)
                    {
                        throw new ProviderException("Unable to load default FileSystemProvider");
                    }
                }
            }
        }
Beispiel #23
0
        private static void LoadProviders()
        {
            // Avoid claiming lock if providers are already loaded
            if (_provider == null)
            {
                lock (_lock)
                {
                    // Do this again to make sure _provider is still null
                    if (_provider == null)
                    {
                        // Get a reference to the <imageService> section
                        CheeseServiceSection section = (CheeseServiceSection)
                                                       WebConfigurationManager.GetSection
                                                           ("system.web/CheeseService");

                        // Load registered providers and point _provider
                        // to the default provider
                        _providers = new CheeseProviderCollection();
                        ProvidersHelper.InstantiateProviders
                            (section.Providers, _providers,
                            typeof(CheeseProvider));
                        _provider = _providers[section.DefaultProvider];

                        if (_provider == null)
                        {
                            throw new ProviderException
                                      ("Unable to load default ImageProvider");
                        }
                    }
                }
            }
        }
Beispiel #24
0
        private static void LoadProviders()
        {
            // Avoid claiming lock if providers are already loaded
            if (_provider == null)
            {
                lock (_lock)
                {
                    // Do this again to make sure _provider is still null
                    if (_provider == null)
                    {
                        // Get a reference to the <imageService> section
                        ThisConfig = (Commerce.Providers.FulfillmentServiceSection)
                                     WebConfigurationManager.GetSection
                                         ("FulfillmentService");

                        // Load registered providers and point _provider
                        // to the default provider
                        _providers = new FulfillmentProviderCollection();
                        ProvidersHelper.InstantiateProviders(ThisConfig.Providers, _providers, typeof(FulfillmentProvider));
                        _provider = (FulfillmentProvider)_providers[ThisConfig.DefaultProvider];

                        if (_provider == null)
                        {
                            throw new ProviderException
                                      ("Unable to load default FulfillmentProvider");
                        }
                    }
                }
            }
        }
Beispiel #25
0
        internal CacheStoreProvider GetObjectCache(bool createIfDoesNotExist)
        {
            if (_objectCache == null && createIfDoesNotExist)
            {
                lock (this) {
                    if (_objectCache == null)
                    {
                        NameValueCollection cacheProviderSettings = HostingEnvironment.CacheStoreProviderSettings;

                        if (cacheProviderSettings != null)
                        {
                            string providerName = (string)cacheProviderSettings["name"]; // Grab this now, as InstantiateProvider will remove it from settings
                            cacheProviderSettings["isPublic"] = "true";
                            _objectCache = (CacheStoreProvider)ProvidersHelper.InstantiateProvider(cacheProviderSettings, typeof(CacheStoreProvider));
                            _objectCache.Initialize(providerName, cacheProviderSettings);
                        }
                        else
                        {
                            if (_internalCache is AspNetCache)
                            {
                                _objectCache = new AspNetCache((AspNetCache)_internalCache, isPublic: true);
                            }
                            else
                            {
                                _objectCache = new AspNetCache(isPublic: true);
                            }
                            _objectCache.Initialize(null, new NameValueCollection());
                        }
                    }
                }
            }

            return(_objectCache);
        }
        private static void Initialize()
        {
            HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, SR.Feature_not_supported_at_this_level);

            if (_initialized)
            {
                return;
            }

            lock (_initializationLock) {
                if (_initialized)
                {
                    return;
                }

                WebPartsSection         webPartsSection = RuntimeConfig.GetAppConfig().WebParts;
                WebPartsPersonalization personalization = webPartsSection.Personalization;

                Debug.Assert(_providers == null);
                _providers = new PersonalizationProviderCollection();

                ProvidersHelper.InstantiateProviders(personalization.Providers, _providers, typeof(PersonalizationProvider));
                _providers.SetReadOnly();
                _provider = _providers[personalization.DefaultProvider];
                if (_provider == null)
                {
                    throw new ConfigurationErrorsException(
                              SR.GetString(SR.Config_provider_must_exist, personalization.DefaultProvider),
                              personalization.ElementInformation.Properties["defaultProvider"].Source,
                              personalization.ElementInformation.Properties["defaultProvider"].LineNumber);
                }

                _initialized = true;
            }
        }
Beispiel #27
0
        // Instantiates and manages the viewstate providers according to the
        // registered providers in the "viewStateServices" section in web.config.

        private static void LoadProviders()
        {
            // providers are loaded just once
            if (provider == null)
            {
                // Synchronize the process of loading the providers
                lock (locker)
                {
                    // Confirm that _provider is still null
                    if (provider == null)
                    {
                        // Get a reference to the <viewstateService> section
                        var section = (ViewStateProviderServiceSection)
                                      WebConfigurationManager.GetSection("myviewstateSection/viewstateService");

                        // Load all registered providers
                        providers = new ViewStateProviderCollection();

                        ProvidersHelper.InstantiateProviders
                            (section.Providers, providers,
                            typeof(ViewStateProviderBase));

                        // Set _provider to the default provider
                        provider = providers[section.DefaultProvider];
                    }
                }
            }
        }
Beispiel #28
0
        /// <summary>
        /// Load all cache providers.
        /// </summary>
        private static void LoadProviders()
        {
            // Avoid claiming lock if providers are already loaded
            if (defaultProvider == null)
            {
                lock (lockObject)
                {
                    // Do this again to make sure defaultProvider is still null
                    if (defaultProvider == null)
                    {
                        // Get a reference to the <cachingService> section
                        cacheSettingsSection = (CacheSettingsSection)WebConfigurationManager.GetSection("dbSharper/cachingService/cacheSettings");

                        // Get a reference to the <cachingService> section
                        CacheProvidersSection cacheProvidersSection = (CacheProvidersSection)WebConfigurationManager.GetSection("dbSharper/cachingService/providers");

                        // Load registered providers and point provider
                        // to the default provider
                        providers = new CacheProviderCollection();

                        ProvidersHelper.InstantiateProviders(cacheProvidersSection.Providers, providers, typeof(CacheProvider));

                        defaultProvider = providers[cacheProvidersSection.DefaultProvider];

                        if (defaultProvider == null)
                        {
                            throw new ProviderException("Unable to load default CacheProvider.");
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Loads the provider which is configured in applicaiton config file (app.config / web.config)
        /// <example>
        /// <![CDATA[<?xml version="1.0" encoding="utf-8" ?>]]>
        ///	<configSections>
        ///	<section name="indexusNetSharedCache" type="SharedCache.WinServiceCommon.Configuration.Client.IndexusProviderSection, SharedCache.WinServiceCommon" />
        ///	</configSections>
        ///
        /// <indexusNetSharedCache defaultProvider="IndexusSharedCacheProvider">
        ///		<servers>
        ///		   <add key="Server1"	ipaddress="10.0.0.3" port="48888" />
        ///		   <add key="Server2"	ipaddress="10.0.0.4" port="48888" />
        ///		</servers>
        ///		<providers>
        ///		   <add
        ///		     name="IndexusSharedCacheProvider"
        ///		     type="SharedCache.WinServiceCommon.Provider.Cache.IndexusSharedCacheProvider, SharedCache.WinServiceCommon" />
        ///		 </providers>
        ///	</indexusNetSharedCache>
        /// </example>
        /// </summary>
        private static void LoadProvider()
        {
            if (providerBase == null)
            {
                lock (bulkObject)
                {
                    if (providerBase == null)
                    {
                        // get a reference to the <cacheProvider> section
                        providerSection = (IndexusServerProviderSection)WebConfigurationManager.GetSection("replicatedSharedCache");

                        // load registered provider and point provider base to the default provider
                        providerCollection = new IndexusServerProviderCollection();
                        ProvidersHelper.InstantiateProviders(
                            providerSection.Providers,
                            providerCollection,
                            typeof(IndexusServerProviderBase)
                            );

                        providerBase = providerCollection[providerSection.DefaultProvider];

                        if (providerBase == null)
                        {
                            throw new ProviderException(@"Unable to load default replication shared Cache Provider!");
                        }
                    }
                }
            }
        }
Beispiel #30
0
        private static void Initialize()
        {
            ProviderConfiguration configuration =
                (ProviderConfiguration)ConfigurationManager.GetSection("portal-providers");

            if (configuration == null)
            {
                throw new ConfigurationErrorsException
                          ("The portal-providers configuration section is not set correctly.");
            }

            providers = new PortalProviderCollection();

            ProvidersHelper.InstantiateProviders(configuration.Providers
                                                 , providers, typeof(PortalProviderBase));

            providers.SetReadOnly();

            defaultProvider = providers[configuration.Default];

            if (defaultProvider == null)
            {
                throw new Exception("No default settings provider is defined for the portal-providers section.");
            }
        }