1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System.Text;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Hosting;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Logging.Console;
- using WarcViewerBlazorWinForm.Backend.Logging;
- using WarcViewerBlazorWinForm.Library.AssemblyInject;
- using WarcViewerBlazorWinForm.Library.EventBus;
- namespace WarcViewerBlazorWinForm
- {
- internal class Program
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- private static void Main()
- {
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
- ApplicationConfiguration.Initialize();
- Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
- //TestCases.Run().Wait;
- var builder = Host.CreateDefaultBuilder();
- var mainForm = new ViewerMainForm();
- var loggingIntoEventBus = new LoggingIntoEventBus();
- builder.ConfigureServices((ctx, services) =>
- {
- //¿ØÖÆ̨ÈÕÖ¾¸ñʽ
- services.AddLogging(opt =>
- {
- opt.AddSimpleConsole(p =>
- {
- p.TimestampFormat = "[dd HH:mm:ss] ";
- p.SingleLine = true;
- p.ColorBehavior = LoggerColorBehavior.Enabled;
- })
- .AddDebug()
- .AddProvider(loggingIntoEventBus);
- services.AddSingleton(opt);
- });
- services.AddWindowsFormsBlazorWebView();
- services.AddAssemblyInject<Program>();
- services.AddBootstrapBlazor();
- services.AddSingleton(mainForm);
- });
- var host = builder.Build();
- var serviceProvider = host.Services;
- loggingIntoEventBus.EventBus = serviceProvider.GetRequiredService<IEventBus>();
- mainForm.ServiceProvider = serviceProvider;
- host.Start();
- Application.Run(mainForm);
- host.StopAsync().Wait();
- }
- }
- }
|