Inheritance: System.Configuration.Provider.ProviderBase
Ejemplo n.º 1
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");
                        }
                    }
                }
            }
            if (_fileStorageProvider == null)
            {
                lock (TheLock)
                {
                    if (_fileStorageProvider == null)
                    {
                        var section = (BlogFileSystemProviderSection)WebConfigurationManager.GetSection("BlogEngine/blogFileSystemProvider");
                        _fileProviders = new BlogFileSystemProviderCollection();
                        ProvidersHelper.InstantiateProviders(section.Providers, _fileProviders, typeof(BlogFileSystemProvider));
                        _fileStorageProvider = _fileProviders[section.DefaultProvider];
                        if (_fileStorageProvider == null)
                        {
                            throw new ProviderException("unable to load default file system Blog Provider");
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
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");
                        }
                    }
                }
            }
            if (_fileStorageProvider == null)
            {
                lock (TheLock)
                {
                    if (_fileStorageProvider == null)
                    {
                        var section = (BlogFileSystemProviderSection)WebConfigurationManager.GetSection("BlogEngine/blogFileSystemProvider");
                        _fileProviders = new BlogFileSystemProviderCollection();
                        ProvidersHelper.InstantiateProviders(section.Providers, _fileProviders, typeof(BlogFileSystemProvider));
                        _fileStorageProvider = _fileProviders[section.DefaultProvider];
                        if (_fileStorageProvider == null)
                        {
                            throw new ProviderException("unable to load default file system Blog Provider");
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 internal static void ReloadFileSystemProvider()
 {
     _fileStorageProvider = null;
     LoadProviders();
 }
Ejemplo n.º 4
0
 internal static void ReloadFileSystemProvider()
 {
     _fileStorageProvider = null;
     LoadProviders();
 }