I have a Service Fabric asp.net core stateless service which implements custom middleware. In that middleware I need access to my service instance. How would I go about injecting this using asp.net core's built-in DI/IoC system?
public class MyMiddleware
{
private readonly RequestDelegate _next;
public MyMiddleware(RequestDelegate next)
{
_next = next;
}
public Task Invoke(HttpContext httpContext)
{
// ** need access to service instance here **
return _next(httpContext);
}
}
Someone mentioned accomplishing this using TinyIoC in Web Api 2 in the Apr 20, 2017 Q&A #11 [45:30] with the Service Fabric team. As well that the current recommended method is to use asp.net core.
Any help or examples would be greatly appreciated!