/// <summary> /// Load config file. /// Defaults, you can use 'null' parameter, Web project maybe find web.config, winform project maybe find /// app.config. /// </summary> /// <param name="configurationManager">The configurationManager.</param> public static void LoadConfig(System.Configuration.Configuration configurationManager) { if (configurationManager == null) { //cfgSection = (APQuerySection)WebConfigurationManager.GetSection("APQuery"); cfgSection = (APQuerySection)ConfigurationManager.GetSection("APQuery"); } else { cfgSection = (APQuerySection)configurationManager.GetSection("APQuery"); } if (cfgSection == null) { throw new ConfigurationErrorsException(APResource.GetString(APResource.APConfig_NotFindSection, "APQuery")); } providersCollection = new APDalProviderCollection(); ProvidersHelper.InstantiateProviders(cfgSection.Providers, providersCollection, typeof(APDalProvider)); defaultProvider = Providers[cfgSection.DefaultProvider]; if (defaultProvider == null) { throw new ConfigurationErrorsException(APResource.GetString(APResource.APProvider_NotFound, cfgSection.DefaultProvider)); } }
/// <summary> /// Load config file. /// Defaults, you can use 'null' parameter, Web project maybe find web.config, winform project maybe find /// app.config. /// </summary> /// <param name="configurationManager">The configurationManager.</param> public static void LoadConfig(System.Configuration.Configuration configurationManager) { if (configurationManager == null) { //cfgSection = (APQuerySection)WebConfigurationManager.GetSection("APQuery"); cfgSection = (APQuerySection)ConfigurationManager.GetSection("APQuery"); } else { cfgSection = (APQuerySection)configurationManager.GetSection("APQuery"); } if (cfgSection == null) throw new ConfigurationErrorsException(APResource.GetString(APResource.APConfig_NotFindSection, "APQuery")); providersCollection = new APDalProviderCollection(); ProvidersHelper.InstantiateProviders(cfgSection.Providers, providersCollection, typeof(APDalProvider)); defaultProvider = Providers[cfgSection.DefaultProvider]; if (defaultProvider == null) throw new ConfigurationErrorsException(APResource.GetString(APResource.APProvider_NotFound, cfgSection.DefaultProvider)); }