CodeTemplateFactory.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Collections;
  2. using System.IO;
  3. using UnityEngine;
  4. namespace GFGEditor
  5. {
  6. public class CodeTemplateFactory
  7. {
  8. public static string ConfigTemplate { get; private set; }
  9. public static string ConfigArrayTemplate { get; private set; }
  10. public static string ConstructorTemplate { get; private set; }
  11. public static string FunctionSingleTemplate { get; private set; }
  12. public static string FunctionGroupTemplate { get; private set; }
  13. public static string FunctionAllTemplate { get; private set; }
  14. public static string FunctionAllSingleBlockTemplate { get; private set; }
  15. public static string FunctionAllGroupBlockTemplate { get; private set; }
  16. //public static string ConfigTemplateEditor { get => _configTemplateEditor; }
  17. //public static string ConfigArrayTemplateEditor { get => _configArrayTemplateEditor; }
  18. public static void Init()
  19. {
  20. ConfigTemplate = File.ReadAllText(ExcelConfig.templatePath + "Config.txt");
  21. //using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "Config.txt"))
  22. //{
  23. // ConfigTemplate = sr.ReadToEnd();
  24. //}
  25. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "ConfigArray.txt"))
  26. {
  27. ConfigArrayTemplate = sr.ReadToEnd();
  28. }
  29. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "Constructor.txt"))
  30. {
  31. ConstructorTemplate = sr.ReadToEnd();
  32. }
  33. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionSingle.txt"))
  34. {
  35. FunctionSingleTemplate = sr.ReadToEnd();
  36. }
  37. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionGroup.txt"))
  38. {
  39. FunctionGroupTemplate = sr.ReadToEnd();
  40. }
  41. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionAll.txt"))
  42. {
  43. FunctionAllTemplate = sr.ReadToEnd();
  44. }
  45. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionAllSingleBlock.txt"))
  46. {
  47. FunctionAllSingleBlockTemplate = sr.ReadToEnd();
  48. }
  49. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionAllGroupBlock.txt"))
  50. {
  51. FunctionAllGroupBlockTemplate = sr.ReadToEnd();
  52. }
  53. }
  54. }
  55. }