#pragma warning disable SYSLIB1045 using System.Text.RegularExpressions; using BITKit; using IDIS_Server_SIM.Data; using IDIS.Services; await BITAppForNet.InitializeAsync("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 + "/IDIS_Server-SIM.xml",true); }); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); var app = builder.Build(); var logger = app.Services.GetRequiredService>(); // #region 输入二级节点地址 // // logger.LogInformation("请输入二级节点地址,例如:88.123.99"); // string? str; // while (true) // { // str = Console.ReadLine(); // if (string.IsNullOrEmpty(str)) // { // str = "88.123.99"; // break; // } // const string pattern =@"^\d{1,3}\.\d{1,3}\.\d{1,3}$"; // 正则表达式模式 // if (Regex.IsMatch(str,pattern)) // { // break; // } // logger.LogInformation("错误的地址格式,请按照正确格式输入,例如:88.123.99"); // } // logger.LogInformation("输入的地址符合要求。"); // // #endregion var idis_Service = app.Services.GetRequiredService(); //idis_Service.PreAddress = str!; app.Services.GetRequiredService(); // Configure the HTTP request pipeline. //if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.MapGet("/", () => "Hello World!"); app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();