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
- {
-
-
-
- [STAThread]
- private static void Main()
- {
-
-
- ApplicationConfiguration.Initialize();
- Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
-
- 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();
- }
- }
- }
|