SimpleInjectorAspNetCoreIntegrationExtensionsUseMiddleware Method (IApplicationBuilder, Type, Container)

Simple Injector
Adds a middleware type to the application's request pipeline. The middleware will be resolved from the supplied the Simple Injector container. The middleware will be added to the container for verification.

Namespace:  SimpleInjector
Assembly:  SimpleInjector.Integration.AspNetCore (in SimpleInjector.Integration.AspNetCore.dll) Version: 5.0.0
Syntax

public static IApplicationBuilder UseMiddleware(
	this IApplicationBuilder app,
	Type middlewareType,
	Container container
)

Parameters

app
Type: IApplicationBuilder
The IApplicationBuilder instance.
middlewareType
Type: SystemType
The middleware type that needs to be applied. This type must implement IMiddleware.
container
Type: SimpleInjectorContainer
The container to resolve middlewareType from.

Return Value

Type: IApplicationBuilder
The supplied IApplicationBuilder instance.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IApplicationBuilder. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions

ExceptionCondition
ArgumentNullExceptionThrown when one of the arguments is a null reference.
ArgumentExceptionThrown when the middlewareType does not derive from IMiddleware, is an open-generic type, or not a concrete constructable type.
See Also

Reference