Config.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. namespace SiteCore.ueditor
  6. {
  7. /// <summary>
  8. /// Config 的摘要说明
  9. /// </summary>
  10. public static class Config
  11. {
  12. private static bool noCache = true;
  13. private static JObject BuildItems()
  14. {
  15. var json = File.ReadAllText(webConfig.framework + "/ueditor/config.json");
  16. return JObject.Parse(json);
  17. }
  18. public static JObject Items
  19. {
  20. get
  21. {
  22. if (noCache || _Items == null)
  23. {
  24. _Items = BuildItems();
  25. }
  26. return _Items;
  27. }
  28. }
  29. private static JObject _Items;
  30. public static T GetValue<T>(string key)
  31. {
  32. return Items[key].Value<T>();
  33. }
  34. public static String[] GetStringList(string key)
  35. {
  36. return Items[key].Select(x => x.Value<String>()).ToArray();
  37. }
  38. public static String GetString(string key)
  39. {
  40. return GetValue<String>(key);
  41. }
  42. public static int GetInt(string key)
  43. {
  44. return GetValue<int>(key);
  45. }
  46. }
  47. }