vNext Dependency Injection Generic Interface

后端 未结 1 670
南笙
南笙 2020-12-09 20:11

I have created an ASP.Net vNext Web API.

I have successfully used the dependency inection with a simple interface such as this:

services.AddScoped<         


        
相关标签:
1条回答
  • 2020-12-09 20:45

    Following is an example:

    services.TryAdd(ServiceDescriptor.Singleton(typeof(IOptions<>), typeof(OptionsManager<>)));

    Source: https://github.com/aspnet/Options/blob/1.0.0-rc1/src/Microsoft.Extensions.OptionsModel/OptionsServiceCollectionExtensions.cs#L23

    0 讨论(0)
提交回复
热议问题