将依赖事件总线的发布订阅模式,改为直接调用的形式

This commit is contained in:
yang.lee
2023-11-02 15:58:15 +08:00
parent 02e4dbb45a
commit b13574530d
32 changed files with 226 additions and 154 deletions

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.Extensions.DependencyInjection;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
{
public class WareHouseBasedControllerActivator : IControllerActivator
{
public object Create(ControllerContext context)
{
if(context == null) { throw new ArgumentNullException("context"); }
var controllerType = context.ActionDescriptor.ControllerTypeInfo.AsType();
//获取Controller实例
var controller =context.HttpContext.RequestServices.GetRequiredService(controllerType);
//判断是否继承了自定义Controller基类
//if(controller is BaseWareHouseService basedWhSvc)
//{
// basedWhSvc.WareHouseSrv = context.HttpContext.RequestServices.GetRequiredService<IWareHouseService>();
//}
return controller;
}
public void Release(ControllerContext context, object controller)
{
}
}
}