ConfigHelper.cs 1011 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Microsoft.Extensions.Configuration;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Text;
  6. namespace CZFW.Core
  7. {
  8. public class ConfigHelper
  9. {
  10. //private static IConfiguration configs;
  11. public static IConfiguration Configs;
  12. public static TVal GetValue<TVal>(string key)
  13. {
  14. var res = Utility.Parse<TVal>(Configs[key]);
  15. return res;
  16. }
  17. public static string GetCDNPrefix()
  18. {
  19. var res = Configs["CDNPrefix"];
  20. return res;
  21. }
  22. //{
  23. // get
  24. // {
  25. // if (configs == null)
  26. // {
  27. // var builder = new ConfigurationBuilder()
  28. // .SetBasePath(Directory.GetCurrentDirectory())
  29. // .AddJsonFile("appsettings.json", optional: true);
  30. // configs = builder.Build();
  31. // }
  32. // return configs;
  33. // }
  34. //}
  35. }
  36. }