I'm creating Type (by reflection) that is extending ApiController. How can I dynamically register it (It can be registered at startup, no need to do this at runtime).
Long story: So in my application I have multiple interfaces, i.e.:
public interface IMyInterface
{
MyResponse Hello(MyRequest request);
}
The thing that I want to achieve is for each interface create controller that should look like this:
public class IMyInterfaceController : ApiController
{
private readonly IMyInterface _MyInterface;
public IMyInterfaceController (IMyInterface MyInterface)
{
_MyInterface=MyInterface;
}
public MyResponse Hello([FromBody] MyRequest request)
{
return MyInterface.Hello(request);
}
}