ConfigHelper.cs 576 B

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