Beispiel #1
0
        static void Main(string[] args)
        {
            AppSettingsRegister.BindJsonFile("appsettings.json");

            Console.WriteLine(AppSettings.Get.Version);
            Console.WriteLine(Cnf.Get.Code);
            //AppSettings.Get.Version;
            var key = Console.ReadKey();

            if (key.KeyChar == 'r')
            {
                Console.WriteLine();
                Console.WriteLine(AppSettings.Get.Version);
                Console.WriteLine(Cnf.Get.Code);
            }
            Console.ReadKey();
        }
Beispiel #2
0
 /// <summary>
 /// 设置配置文件
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="jsonfilepath">json文件路径</param>
 /// <param name="reloadOnChange">文件被修改时是否自动重新加载</param>
 public static IServiceCollection AddAppSettingsJsonFile(this IServiceCollection builder, string jsonfilepath, bool reloadOnChange = true)
 {
     AppSettingsRegister.BindJsonFile(jsonfilepath, reloadOnChange);
     return(builder);
 }
Beispiel #3
0
 /// <summary>
 /// 设置配置文件
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="jsonfilepath">json文件路径</param>
 /// <param name="reloadOnChange">文件被修改时是否自动重新加载</param>
 public static void AddAppSettingsJsonFile(this IApplicationBuilder builder, string jsonfilepath, bool reloadOnChange = true)
 {
     AppSettingsRegister.BindJsonFile(jsonfilepath, reloadOnChange);
 }