vendredi 11 août 2017

How to get a controller of API project from UI project with DispatchProxy in .NET CORE

I have a few projects in my solution for example UI and API.

I want to create instance a controller from API in UI project by not adding API project to UI project's references.

Like this ( in theory ) ;

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 info enough.
     var proxy = System.Reflection.DispatchProxy.Create<T, TProxy>();
     return proxy;
}

Like this ( practically ) in UI controller ;

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.

How can i do it ?





Aucun commentaire:

Enregistrer un commentaire