C# 如何在ASP.NET内核中使用DispatchProxy从UI项目中获取API项目的控制器
我的解决方案中有一些项目,例如UI和API 我希望从UI项目中的API项目创建控制器实例,而无需将UI项目中的引用添加到API项目中 像这样:C# 如何在ASP.NET内核中使用DispatchProxy从UI项目中获取API项目的控制器,c#,reflection,proxy,asp.net-core,dispatch,C#,Reflection,Proxy,Asp.net Core,Dispatch,我的解决方案中有一些项目,例如UI和API 我希望从UI项目中的API项目创建控制器实例,而无需将UI项目中的引用添加到API项目中 像这样: public T CreateProxy<T>() { // There is a code like this. I don't know how to use it. // I researched it, but I couldn't get enough info. var proxy = System.
public T CreateProxy<T>()
{
// There is a code like this. I don't know how to use it.
// I researched it, but I couldn't get enough info.
var proxy = System.Reflection.DispatchProxy.Create<T, TProxy>();
return proxy;
}
public T CreateProxy()
{
//有这样的代码,我不知道怎么用。
//我研究过了,但我得不到足够的信息。
var proxy=System.Reflection.DispatchProxy.Create();
返回代理;
}
用户界面控制器:
IParameterApi = CreateProxy<IParameterApi>();
// ParameterController is coming from API.
//( i dont know how to map it. dependency injection or what ? )
// and I've got this controllers Add, Update, Remove and more methods that I can use.
IParameterApi=CreateProxy();
//ParameterController来自API。
//(我不知道如何映射它。依赖注入还是什么?)
//我有这个控制器,可以添加、更新、删除和使用更多的方法。
我该怎么做