#pragma warning disable SYSLIB1045 using BITKit; using BITKit.Net; using CAICT.IDIS.Service; using CN.CAICT.IDIS; using IDIS.Model; using Net.BITKit.Teleport; using Newtonsoft.Json; await BITAppForNet.InitializeAsync("CN.CAICT.IDIS"); var config = Path.Combine(Environment.CurrentDirectory,"appsettings.json"); if (File.Exists(config)) { var json = File.ReadAllText(config); DataParser.Set(json); } var builder = WebApplication.CreateBuilder(args); var cancellationTokenSource = new System.Threading.CancellationTokenSource(); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(x => { var currentDirectory = AppContext.BaseDirectory; x.IncludeXmlComments(currentDirectory + "/CN.CAICT.IDIS.xml",true); }); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(x => x.GetRequiredService().NetProvider); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); var app = builder.Build(); var server = app.Services.GetRequiredService(); server.StartServer(29755); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.MapGet("/", () => "Hello World!"); app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); new Thread(Tick).Start(); await app.RunAsync(); return; async void Tick() { app.Services.QueryComponents(out ILogger logger); while (true) { try { server.NetProvider.Tick(); } catch (Exception exception) { logger.LogCritical(exception,exception.Message); } //logger.LogInformation("wait next frame"); await Task.Delay(16); } logger.LogCritical("程序已退出,不应该出现"); }