Configuration.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Bowin.Common.Utility;
  2. using Microsoft.Extensions.Configuration;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. namespace OrderSystem.Web
  9. {
  10. public class Configuration
  11. {
  12. public static Configuration Current
  13. {
  14. get
  15. {
  16. var configuration = new ConfigurationBuilder()
  17. .SetBasePath(Directory.GetCurrentDirectory())
  18. .AddJsonFile("appsettings.json")
  19. .Build();
  20. Configuration result = new Configuration();
  21. result.AppSettings = configuration.GetSection("AppSettings").Get<AppSettings>();
  22. result.CROSDomainList = configuration.GetSection("Web")
  23. .GetSection("Cros")
  24. .GetValue<string>("Domain")
  25. .Split(",", StringSplitOptions.RemoveEmptyEntries)
  26. .Select(x => x.Trim()).ToList();
  27. result.WxConfig = configuration.GetSection("WxConfig").Get<WxConfig>();
  28. return result;
  29. }
  30. }
  31. public AppSettings AppSettings { get; set; }
  32. public List<string> CROSDomainList { get; set; }
  33. public WxConfig WxConfig { get; set; }
  34. }
  35. public class AppSettings
  36. {
  37. /*public string TemplatePath { get; set; }
  38. public string PicturePath { get; set; }
  39. public string FilePath { get; set; }
  40. public string TemplatePhysicalPath
  41. {
  42. get
  43. {
  44. return HttpHelper.MapPath(TemplatePath);
  45. }
  46. }*/
  47. public string H5BasePath { get; set; }
  48. public string H5Version { get; set; }
  49. }
  50. public class WxConfig
  51. {
  52. public string AppId { get; set; }
  53. public string AppSecret { get; set; }
  54. public string RedirectURI { get; set; }
  55. }
  56. }