12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System.Text;
- using Bmp.Core.Common.AssemblyInject;
- using Bmp.Core.Common.Logging;
- using Microsoft.Extensions.Logging.Console;
- namespace Bmp.WinForms;
- internal class Program
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- private static void Main()
- {
- Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
- ApplicationConfiguration.Initialize();
- var loggingIntoEventBus = new LoggingIntoEventBus();
- var builder = Host.CreateDefaultBuilder();
- 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();
- host.Start();
- var mainForm = host.Services.GetRequiredService<MainForm>();
- Application.Run(mainForm);
- host.StopAsync().Wait();
- }
- }
|