CodeTemplateFactory.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 DisposeTemplate { get; private set; }
  12. public static string FunctionSingleTemplate { get; private set; }
  13. public static string FunctionGroupTemplate { get; private set; }
  14. public static string FunctionAllTemplate { get; private set; }
  15. public static string FunctionAllSingleBlockTemplate { get; private set; }
  16. public static string FunctionAllGroupBlockTemplate { get; private set; }
  17. public static string DisposeAllCfgsCacheTemplate { get; private set; }
  18. public static string FunctionDisposeTemplate { get; private set; }
  19. public static string StrCfgArrayDisposeTemplate { get; private set; }
  20. //public static string ConfigTemplateEditor { get => _configTemplateEditor; }
  21. //public static string ConfigArrayTemplateEditor { get => _configArrayTemplateEditor; }
  22. public static void Init()
  23. {
  24. ConfigTemplate = File.ReadAllText(ExcelConfig.templatePath + "Config.txt");
  25. //using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "Config.txt"))
  26. //{
  27. // ConfigTemplate = sr.ReadToEnd();
  28. //}
  29. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "ConfigArray.txt"))
  30. {
  31. ConfigArrayTemplate = sr.ReadToEnd();
  32. }
  33. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "Constructor.txt"))
  34. {
  35. ConstructorTemplate = sr.ReadToEnd();
  36. }
  37. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "Dispose.txt"))
  38. {
  39. DisposeTemplate = sr.ReadToEnd();
  40. }
  41. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionSingle.txt"))
  42. {
  43. FunctionSingleTemplate = sr.ReadToEnd();
  44. }
  45. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionGroup.txt"))
  46. {
  47. FunctionGroupTemplate = sr.ReadToEnd();
  48. }
  49. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionAll.txt"))
  50. {
  51. FunctionAllTemplate = sr.ReadToEnd();
  52. }
  53. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionAllSingleBlock.txt"))
  54. {
  55. FunctionAllSingleBlockTemplate = sr.ReadToEnd();
  56. }
  57. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionAllGroupBlock.txt"))
  58. {
  59. FunctionAllGroupBlockTemplate = sr.ReadToEnd();
  60. }
  61. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "DisposeAllCfgsCache.txt"))
  62. {
  63. DisposeAllCfgsCacheTemplate = sr.ReadToEnd();
  64. }
  65. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionDispose.txt"))
  66. {
  67. FunctionDisposeTemplate = sr.ReadToEnd();
  68. }
  69. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "StrCfgArrayDisposeBlock.txt"))
  70. {
  71. StrCfgArrayDisposeTemplate = sr.ReadToEnd();
  72. }
  73. }
  74. }
  75. }