|
|
|
using Autofac;
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
using DS.Module.AutofacModule;
|
|
|
|
using DS.Module.PrintModule;
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
|
|
namespace Ds.WMS.Test;
|
|
|
|
|
|
|
|
public class Startup
|
|
|
|
{
|
|
|
|
// 自定义 host 构建
|
|
|
|
public void ConfigureHost(IHostBuilder hostBuilder)
|
|
|
|
{
|
|
|
|
//hostBuilder.ConfigureAppConfiguration(builder =>
|
|
|
|
//{
|
|
|
|
// // 注册配置
|
|
|
|
// builder.AddInMemoryCollection(new Dictionary<string, string>()
|
|
|
|
// {
|
|
|
|
// {"UserName", "Alice"}
|
|
|
|
// }).AddJsonFile("appsettings.json");
|
|
|
|
//})
|
|
|
|
//.ConfigureServices((context, services) =>
|
|
|
|
//{
|
|
|
|
// // 注册自定义服务
|
|
|
|
// services.AddSingleton<IIdGenerator, GuidIdGenerator>();
|
|
|
|
// if (context.Configuration.GetAppSetting<bool>("XxxEnabled"))
|
|
|
|
// {
|
|
|
|
// services.AddSingleton<IUserIdProvider, EnvironmentUserIdProvider>();
|
|
|
|
// }
|
|
|
|
//});
|
|
|
|
//Autofac注入
|
|
|
|
hostBuilder
|
|
|
|
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
|
|
|
.ConfigureContainer<ContainerBuilder>(builder => { builder.RegisterModule(new AutofacModuleRegister()); });
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// 支持的形式:
|
|
|
|
/// ConfigureServices(IServiceCollection services)
|
|
|
|
/// ConfigureServices(IServiceCollection services, HostBuilderContext hostBuilderContext)
|
|
|
|
/// ConfigureServices(HostBuilderContext hostBuilderContext, IServiceCollection services)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="services"></param>
|
|
|
|
/// <param name="hostBuilderContext"></param>
|
|
|
|
public void ConfigureServices(IServiceCollection services, HostBuilderContext hostBuilderContext)
|
|
|
|
{
|
|
|
|
// services.AddTransient<ITestService, TestService>();
|
|
|
|
services.AddUserModuleInstall(); //用户服务
|
|
|
|
services.AddSqlSugarInstall();
|
|
|
|
services.AddSaasDbInstall();
|
|
|
|
services.AddPrintModuleInstall();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 可以添加要用到的方法参数,会自动从注册的服务中获取服务实例,类似于 asp.net core 里 Configure 方法
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="provider"></param>
|
|
|
|
public void Configure(IServiceProvider provider)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|