ConfigHelper.cs 468 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.IO;
  3. namespace ETModel
  4. {
  5. public static class ConfigHelper
  6. {
  7. public static string GetText(string key)
  8. {
  9. string path = $"../Config/{key}.txt";
  10. try
  11. {
  12. string configStr = File.ReadAllText(path);
  13. return configStr;
  14. }
  15. catch (Exception e)
  16. {
  17. throw new Exception($"load config file fail, path: {path} {e}");
  18. }
  19. }
  20. public static T ToObject<T>(string str)
  21. {
  22. return MongoHelper.FromJson<T>(str);
  23. }
  24. }
  25. }