Program.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Reflection;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. namespace CmwtatDigital
  10. {
  11. public static class Program
  12. {
  13. public static bool autoact = false;
  14. public static bool hiderun = false;
  15. public static bool expact = false;
  16. public static bool log2file = false;
  17. public static bool showhelp = false;
  18. /// <summary>
  19. /// Application Entry Point.
  20. /// </summary>
  21. [System.STAThreadAttribute()]
  22. [System.Diagnostics.DebuggerNonUserCodeAttribute()]
  23. [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
  24. public static void Main(string[] startup_args)
  25. {
  26. var loadedAssemblies = new Dictionary<string, Assembly>();
  27. AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
  28. {
  29. String resourceName = "CmwtatDigital.Res." +
  30. new AssemblyName(args.Name).Name + ".dll";
  31. //Must return the EXACT same assembly, do not reload from a new stream
  32. if (loadedAssemblies.TryGetValue(resourceName, out Assembly loadedAssembly))
  33. {
  34. return loadedAssembly;
  35. }
  36. using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
  37. {
  38. if (stream == null)
  39. return null;
  40. Byte[] assemblyData = new Byte[stream.Length];
  41. stream.Read(assemblyData, 0, assemblyData.Length);
  42. var assembly = Assembly.Load(assemblyData);
  43. loadedAssemblies[resourceName] = assembly;
  44. return assembly;
  45. }
  46. };
  47. foreach (string arg in startup_args)
  48. {
  49. Console.WriteLine("arg: " + arg);
  50. if (arg == "-a" || arg == "--auto")
  51. {
  52. Console.WriteLine("AUTO: True");
  53. autoact = true;
  54. }
  55. if (arg == "-h" || arg == "--hide")
  56. {
  57. Console.WriteLine("HIDE: True");
  58. hiderun = true;
  59. }
  60. if (arg == "-e" || arg == "--expact")
  61. {
  62. Console.WriteLine("EXPACT: True");
  63. expact = true;
  64. }
  65. if (arg == "-l" || arg == "--log")
  66. {
  67. Console.WriteLine("LOG: True");
  68. log2file = true;
  69. }
  70. if (arg == "-?" || arg == "--help")
  71. {
  72. Console.WriteLine("SHOWHELP: True");
  73. showhelp = true;
  74. }
  75. }
  76. CmwtatDigital.App app = new CmwtatDigital.App();//WPF项目的Application实例,用来启动WPF项目的
  77. app.InitializeComponent();
  78. app.Run();
  79. }
  80. }
  81. }