You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.6 KiB
C#

10 months ago
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SlnMesnac.Config;
using SlnMesnac.Common;
using SlnMesnac.Repository;
using SlnMesnac.Plc;
using SlnMesnac.Serilog;
using System;
using Microsoft.Extensions.Configuration;
using SlnMesnac.Business;
using SlnMesnac.Mqtt;
using SlnMesnac.Rfid;
using SlnMesnac.TouchSocket;
10 months ago
namespace SlnMesnac.WPF
{
/// <summary>
///
/// </summary>
public class Startup
{
/// <summary>
/// This method gets called by the runtime. Use this method to add services to the container.
/// </summary>
/// <param name="services"></param>
[Obsolete]
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
//注册AppConfig
10 months ago
services.AddSingleton<AppConfig>(provider =>
{
var configuration = provider.GetService<IConfiguration>();
return configuration.GetSection("AppConfig").Get<AppConfig>();
});
//注册通用类
services.AddCommonSetup();
10 months ago
//注册ORM
10 months ago
services.AddSqlSugarSetup();
//注册Service
10 months ago
services.AddServices();
//注册Quartz
//services.AddQuartzSetUp();
10 months ago
//注册PLC
services.AddPlcSetup();
//注册MQTT
//services.AddMqttSetup();
//注册TouchSocket
services.AddTouchSocketSetup();
//注册RFID
//services.AddRfidSetup();
services.AddBusinessSetup();
10 months ago
}
/// <summary>
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
//启用Serilog中间件
app.UseSerilogExtensions();
//初始化PLC中间件
app.UsePlcExtensions();
app.UseTouchSocketExtensions();
app.UseBusinessExtensions();
//初始化RFID中间件
//app.UseRfidExtensions();
10 months ago
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}