Program.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using FlutterCodeGenerator.Helper;
  2. using FlutterCodeGenerator.Model;
  3. using System;
  4. using System.Diagnostics;
  5. using System.IO;
  6. namespace FlutterCodeGenerator
  7. {
  8. internal class Program
  9. {
  10. private static void Main(string[] args)
  11. {
  12. try
  13. {
  14. var generatedFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GeneratedCode");
  15. var dllPath = AppDomain.CurrentDomain.BaseDirectory;
  16. if (args.Length == 2)
  17. {
  18. dllPath = args[0];
  19. generatedFolderPath = args[1];
  20. }
  21. if (string.IsNullOrWhiteSpace(dllPath) || string.IsNullOrWhiteSpace(generatedFolderPath))
  22. {
  23. throw new ArgumentException("The argments are invalid!");
  24. }
  25. var codeGeneratorForWing = new CodeGeneratorForWing(dllPath, generatedFolderPath);
  26. codeGeneratorForWing.GeneratedCode();
  27. var codeGeneratorForFISLib = new CodeGeneratorForFISLib(dllPath, generatedFolderPath);
  28. codeGeneratorForFISLib.GeneratedCode();
  29. using (Process process = new Process())
  30. {
  31. ProcessStartInfo psi = new ProcessStartInfo("Explorer.exe")
  32. {
  33. Arguments = generatedFolderPath
  34. };
  35. process.StartInfo = psi;
  36. process.Start();
  37. }
  38. Console.WriteLine($"The code has already generated! The path is {generatedFolderPath}");
  39. }
  40. catch (Exception ex)
  41. {
  42. Console.WriteLine($"An Error occured when generated!!!CodeGenerator:{GenerateDataCache.Instance.CurrentGenerator}, Service:{GenerateDataCache.Instance.CurrentService},Method:{GenerateDataCache.Instance.CurrentMethod},Parameter:{GenerateDataCache.Instance.CurrentParameter},IsLoadFinished:{GenerateDataCache.Instance.IsLoadFinished},IsGenerateFinished:{GenerateDataCache.Instance.IsGenerateFinished} Error Message : {ex}");
  43. }
  44. Console.ReadLine();
  45. }
  46. }
  47. }