using Microsoft.Extensions.Configuration; using System.IO; namespace HRM.UI.Configurations { /// /// /// public static class ConfigurationHelper { /// /// /// /// /// public static IConfigurationRoot GetIConfigurationRoot(string outputPath) { var configurationBuilder = new ConfigurationBuilder() .SetBasePath(!string.IsNullOrEmpty(outputPath) ? outputPath : Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables(); return configurationBuilder.Build(); } /// /// /// /// /// /// public static IConfigurationRoot GetIConfigurationRoot(string environment, string outputPath) { return new ConfigurationBuilder() .SetBasePath(!string.IsNullOrEmpty(outputPath) ? outputPath : Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{environment}.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables() .Build(); } /// /// /// /// /// /// //public static T GetApplicationConfiguration(string outputPath, IConfigurationRoot iConfig) // public static T GetApplicationConfiguration(IConfigurationRoot iConfig) { var configuration = default(T); iConfig? .GetSection(typeof(T).Name)? .Bind(configuration); return configuration; } /// /// /// /// /// /// public static IConfigurationSection GetConfigurationSection(IConfigurationRoot iConfig) { return iConfig?.GetSection(typeof(T).Name); } } }