Program.cs 998 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Reflection;
  2. using HZY.Framework.DependencyInjection;
  3. using Microsoft.Extensions.DependencyInjection;
  4. namespace Scada
  5. {
  6. internal static class Program
  7. {
  8. /// <summary>
  9. /// The main entry point for the application.
  10. /// </summary>
  11. [STAThread]
  12. static void Main()
  13. {
  14. var services = new ServiceCollection();
  15. ConfigureServices(services);
  16. ApplicationConfiguration.Initialize();
  17. var serviceProvider = services.BuildServiceProvider();
  18. Globals.ServiceProvider = serviceProvider;
  19. var frmMain = serviceProvider.GetRequiredService<FormMain>();
  20. Application.Run(frmMain);
  21. }
  22. private static void ConfigureServices(ServiceCollection services)
  23. {
  24. services.AddDependencyInjection(options =>
  25. {
  26. options.Assemblies = new[] { typeof(Program).Assembly };
  27. });
  28. }
  29. }
  30. }