#pragma warning disable SYSLIB1045 using System.Text.RegularExpressions; using BITKit; using IDIS.Services; await BITAppForNet.InitializeAsync("IDIS"); 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(); builder.Services.AddTransient(); var app = builder.Build(); var logger = app.Services.GetRequiredService>(); #region 输入二级节点地址 logger.LogInformation("请输入二级节点地址,例如:88.123.99"); string? str; while (string.IsNullOrEmpty(str = Console.ReadLine()) is false) { const string pattern =@"^\d{1,3}\.\d{1,3}\.\d{1,3}$"; // 正则表达式模式 if (Regex.IsMatch(str,pattern)) { logger.LogInformation("输入的地址符合要求。"); break; } logger.LogInformation("错误的地址格式,请按照正确格式输入,例如:88.123.99"); } #endregion var idis_Service = app.Services.GetRequiredService(); //idis_Service.PreAddress = str!; // 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();