/// <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.", String.IsNullOrWhiteSpace(_configSectionName) ? typeof(T).FullName : _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; } }