internal static void InstantiateProviders(ProviderSettingsCollection configProviders, ContentManagementProviderCollection providers, Type providerType) { foreach (ProviderSettings settings in configProviders) { providers.Add(InstantiateProvider(settings, providerType)); } }
private static void LoadConfiguration() { if (_provider == null) { lock (syncRoot) { if (_provider == null) { _settings = (ContentManagerSettings) ConfigurationManager.GetSection("contentManagerSettings"); if (_settings == null) throw new ConfigurationErrorsException("Falta la configuración del content manager service"); _providers = new ContentManagementProviderCollection(); if (System.Web.HttpContext.Current != null) { ProvidersHelper.InstantiateProviders( _settings.Providers, _providers, typeof(ContentManagementProvider)); } else { _ProviderHelper.InstantiateProviders( _settings.Providers, _providers, typeof(ContentManagementProvider)); } _provider = _providers[_settings.DefaultProvider]; StringDictionary dic = _provider.LoadSettings(); Type settingsType = _settings.GetType(); foreach (string key in dic.Keys) { string name = key; string value = dic[key]; foreach (PropertyInfo propertyInformation in settingsType.GetProperties()) { if (propertyInformation.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) { try { propertyInformation.SetValue(_settings, Convert.ChangeType(value, propertyInformation.PropertyType, CultureInfo.CurrentCulture), null); } catch { } break; } } } } } } }