-
Notifications
You must be signed in to change notification settings - Fork 12
DependencyInjection
Ian Johnson edited this page Sep 7, 2018
·
1 revision
Service support construction injection by default using the built in DI container or 3rd party container.
By default all non enumerable interfaces parameters will be automatically located from the IServiceProvider. The parameters are not shown in the documentation and expected not to be part of the request.
// callers provide x and y
public int Method(IIntMathService mathService, int x, int y)
{
return mathService.Add(x, y);
}Sometimes you need to request concrete types from the container and not from the caller
public int SomeMethod([FromServices]SomeClass someC, int x, int y)
{
return someC.Method(x, y);
}