/// <summary> /// 构造函数 /// </summary> /// <param name="bootupProvider">启动配置提供者</param> /// <param name="env">当前环境</param> public ConfigurationFactory(IBootupConfigurationProvider bootupProvider, IEnvironment env) { _bootupProvider = bootupProvider; _env = env; _configOptions = new ConfigFactoryOptions(); ConfigurationBinder.Bind(bootupProvider.GetBootupConfiguration().GetSection("Configuration"), _configOptions); _configRootFullPath = System.IO.Path.Combine(env.ContentRootPath, _configOptions.ConfigurationRootPath); }
/// <summary> /// 读取NLog配置文件位置 /// </summary> /// <param name="provider"></param> /// <returns></returns> public static string GetNLogConfigFilePath(this IBootupConfigurationProvider provider) { var configurationSection = provider.GetBootupConfiguration().GetSection("Configuration"); var configurationRootPath = configurationSection.GetSection("ConfigurationRootPath").Value; var configurationFileName = configurationSection.GetSection("NLog").Value; if (configurationFileName == null) { return(null); } else { return(Path.Combine(configurationRootPath, configurationFileName)); } }
/// <summary> /// 读取Autofac配置 /// </summary> /// <param name="provider"></param> /// <returns></returns> public static IConfiguration GetAutofacConfiguration(this IBootupConfigurationProvider provider) { return(provider.GetBootupConfiguration().GetSection("Autofac")); }