ISupportRequiredService Interface

Optional contract used by Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService``1(System.IServiceProvider) to resolve services if supported by System.IServiceProvider.

Namespace
Microsoft.Extensions.DependencyInjection
Assemblies
  • Microsoft.Extensions.DependencyInjection.Abstractions

Syntax

public interface ISupportRequiredService
interface Microsoft.Extensions.DependencyInjection.ISupportRequiredService

Methods

GetRequiredService(System.Type)

Gets service of type <em>serviceType</em> from the System.IServiceProvider implementing this interface.

Arguments:serviceType (System.Type) – An object that specifies the type of service object to get.
Return type:System.Object
Returns:A service object of type <em>serviceType</em>. Throws an exception if the System.IServiceProvider cannot create the object.
object GetRequiredService(Type serviceType)