using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SlnMesnac.Config;
using SlnMesnac.Repository;
using SlnMesnac.Serilog;
using System;
using Autofac;
using Microsoft.Extensions.Configuration;
using SlnMesnac.Ioc;
using SlnMesnac.Plc;
using SlnMesnac.Extensions;
namespace SlnMesnac.WPF
{
///
///
///
public class Startup
{
///
/// This method gets called by the runtime. Use this method to add services to the container.
///
///
[Obsolete]
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
//注册AppConfig
services.AddSingleton(provider =>
{
var configuration = provider.GetService();
return configuration.GetSection("AppConfig").Get();
});
//注册ORM
services.AddSqlSugarSetup();
if (!HslCommunication.Authorization.SetAuthorizationCode("b980977c-3323-4876-b633-c0bef93d75c1"))
{
Console.WriteLine( "active failed" );
Console.ReadLine( );
}
//注册PLC工厂
services.AddPlcFactorySetup();
services.AddHttpClient();
}
///
/// AutoFac自动注入
///
///
public void ConfigureContainer(ContainerBuilder builder)
{
DependencyConfigurator.Configure(builder);
}
///
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
///
///
///
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
//启用Serilog中间件
app.UseSerilogExtensions();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}