https://www.devtrends.co.uk/blog/how-not-to-do-dependency-injection-the-static-or-singleton-container
http://codebetter.com/jeremymiller/2005/09/20/what%E2%80%99s-so-great-about-inversion-of-control/
http://codebetter.com/jeremymiller/2005/10/06/the-dependency-injection-pattern-%E2%80%93-what-is-it-and-why-do-i-care/
ASP.NET Core 2.0
How to resolve service instances inside ConfigureServices in Startup.cs
https://andrewlock.net/accessing-services-when-configuring-mvcoptions-in-asp-net-core/
services.AddTransient<IMyService,MyService>();
services.AddMvc(options => {
// Need instance of MyService here ?
}
There is :
IConfigureOptions
; so you can write this:
services.AddSingleton<IConfigureOptions<MvcOptions>, ConfigureMvcOptions>();
No comments:
Post a Comment