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.

71 lines
2.4 KiB
C#

using Autofac;
using Autofac.Extensions.DependencyInjection;
using DS.Module.AutofacModule;
using DS.Module.PrintModule;
using DS.Module.SqlSugar;
10 months ago
using DS.Module.UserModule;
using DS.Module.RedisModule;
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>();
10 months ago
services.AddUserModuleInstall(); //用户服务
services.AddRedisModuleInstall();//redis
10 months ago
services.AddSqlSugarInstall();
10 months ago
services.AddSaasDbInstall();
services.AddPrintModuleInstall();
}
/// <summary>
/// 可以添加要用到的方法参数,会自动从注册的服务中获取服务实例,类似于 asp.net core 里 Configure 方法
/// </summary>
/// <param name="provider"></param>
public void Configure(IServiceProvider provider)
{
}
}