我有一個實現自定義中間件的服務結構asp.net核心無狀態服務。在那個中間件中我需要訪問我的服務實例。我將如何使用asp.net內核的內置DI/IoC系統注入這些內容?如何將Service Fabric服務上下文注入到asp.net核心中間件?
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);
}
}
有人提到在網絡API 2在Apr 20, 2017 Q&A #11 [45:30]與服務織物團隊完成這個使用TinyIoC。以及目前推薦的方法是使用asp.net核心。
任何幫助或例子將不勝感激!
正是我需要的 - 謝謝! – rktect