Configuration.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 YLShipBuildLandMap.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. return result;
  28. }
  29. }
  30. public AppSettings AppSettings { get; set; }
  31. public static List<string> Assemblies
  32. {
  33. get
  34. {
  35. var configuration = new ConfigurationBuilder()
  36. .SetBasePath(Directory.GetCurrentDirectory())
  37. .AddJsonFile("servicemapping.json")
  38. .Build();
  39. return configuration.GetSection("Assemblies").Get<List<string>>() ?? new List<string>();
  40. }
  41. }
  42. //public List<string> CROSDomainList { get; set; }
  43. }
  44. public class AppSettings
  45. {
  46. public string TemplatePath { get; set; }
  47. public string PicturePath { get; set; }
  48. public string FilePath { get; set; }
  49. public string TemplatePhysicalPath
  50. {
  51. get
  52. {
  53. return HttpHelper.MapPath(TemplatePath);
  54. }
  55. }
  56. }
  57. }