You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
857 B

  1. using Microsoft.Extensions.Configuration;
  2. using Microsoft.Extensions.Configuration.Json;
  3. using System;
  4. namespace DataVAPI.AppConfig
  5. {
  6. public class AppConfigurtaionServices
  7. {
  8. public static IConfiguration Configuration { get; set; }
  9. static AppConfigurtaionServices()
  10. {
  11. //ReloadOnChange = true 当appsettings.json被修改时重新加载
  12. Configuration = new ConfigurationBuilder()
  13. //.SetBasePath(Directory.GetCurrentDirectory())
  14. //AppDomain.CurrentDomain.BaseDirectory是程序集基目录,所以appsettings.json,需要复制一份放在程序集目录下,
  15. .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
  16. .Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true })
  17. .Build();
  18. }
  19. }
  20. }