Environment.cs 688 B

1234567891011121314151617181920212223242526
  1. using Microsoft.Extensions.Configuration;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Text;
  6. namespace Bowin.Common.Utility
  7. {
  8. public class Environment
  9. {
  10. public static IConfigurationRoot GetConfig(string configFileName)
  11. {
  12. var basePath = Directory.GetCurrentDirectory();
  13. if (!File.Exists(Path.Combine(basePath, configFileName)))
  14. {
  15. basePath = AppDomain.CurrentDomain.BaseDirectory;
  16. }
  17. return new ConfigurationBuilder()
  18. .SetBasePath(basePath)
  19. .AddJsonFile(configFileName)
  20. .Build();
  21. }
  22. }
  23. }