mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-07 02:00:51 +08:00
完善autofac模块
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
|
||||
using AspNetCore.Microsoft.AspNetCore.Builder;
|
||||
using Autofac;
|
||||
using System.Reflection;
|
||||
using Yi.Framework.Application;
|
||||
using Yi.Framework.Application.Contracts;
|
||||
using Yi.Framework.Autofac.Extensions;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.AutoMapper;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.Framework.Core.Sqlsugar;
|
||||
@@ -14,7 +16,7 @@ using Yi.Framework.Domain.Shared;
|
||||
using Yi.Framework.Sqlsugar;
|
||||
using Yi.Framework.Web;
|
||||
|
||||
//这里是最早执行的地方
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
|
||||
@@ -32,12 +34,20 @@ builder.UseYiModules(
|
||||
typeof(YiFrameworkApplicationContractsModule).Assembly,
|
||||
typeof(YiFrameworkApplicationModule).Assembly,
|
||||
typeof(YiFrameworkWebModule).Assembly
|
||||
|
||||
|
||||
);
|
||||
|
||||
//使用autofac
|
||||
builder.Host.UseAutoFacServerProviderFactory();
|
||||
|
||||
//添加autofac模块,需要添加模块
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, typeof(YiFrameworkWebModule).Assembly);
|
||||
});
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
var t = app.Services.GetService<Test2Entity>();
|
||||
app.MapControllers();
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user