using System.Net; using System.Reflection; using MassTransit; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Server; Console.WriteLine(BitConverter.IsLittleEndian); var builder = Host.CreateApplicationBuilder(); builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); builder.Logging.AddFile("Logs/Server-{Date}.log", LogLevel.Trace); builder.Logging.AddFile("Logs/Server-{Date}.json.log", isJson: true, minimumLevel: LogLevel.Trace); builder.Services.AddLogging(); builder.Services.AddSingleton(); builder.Services.AddHostedService(provider => provider.GetService() ?? throw new InvalidOperationException()); builder.Services.AddMassTransit(x => { x.UsingInMemory((context, configurator) => { configurator.ConfigureEndpoints(context); }); x.AddMediator(cfg => { cfg.AddConsumers(Assembly.GetExecutingAssembly()); }); }); builder.Services.AddHostedService(provider => new WonderkingAuthServer(IPAddress.Any, 10001, provider.GetService>() ?? throw new InvalidOperationException(), provider.GetService() ?? throw new InvalidOperationException(), provider.GetService() ?? throw new InvalidOperationException())); using IHost host = builder.Build(); await host.RunAsync();