I am trying to get into the new ASP.NET MVC 6 stuff, but it is very difficult for me with their new DI system. I tried to find resources on the Internet, but everything that I find covers only an absolute minimum to use it.
I previously used Ninject , and I have several connections that work as follows:
Bind<IDocumentStore>() .ToMethod(c => CreateDocumentStore()) .InSingletonScope(); private static IDocumentStore CreateDocumentStore() {
But so far, itβs hard for me to find a way to transfer this behavior to the new Microsoft DI system. All I can find are examples:
services.AddTransient<IEmailSender, AuthMessageSender>(); services.AddTransient<ISmsSender, AuthMessageSender>();
and
services.AddMvc();
Where everything seems to work completely with the standard constructor for the target service. Is there a way to create the behavior that I need in this new DI system?
I have seen
services.Configure<TOptions>(options => {});
But I do not quite understand if this will do what I think about, or if it is reserved for a specific behavior.
dependency-injection asp.net-mvc asp.net-core-mvc
Ciel Jul 29 '15 at 8:29 2015-07-29 08:29
source share