using IoTSharp.Gateway.Modbus.Data; using IoTSharp.Gateway.Modbus.Services; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; namespace IoTSharp.Gateway.Modbus { public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); // Add services to the container. var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."); builder.Services.AddDbContext(options => options.UseSqlite(connectionString)); builder.Services.AddDatabaseDeveloperPageExceptionFilter(); builder.Services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount=false) .AddEntityFrameworkStores(); builder.Services.AddRazorPages(); builder.Services.AddHostedService(); builder.Services.AddIoTSharpMqttSdk(builder.Configuration); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.MapRazorPages(); app.Run(); } } }