Class ServiceScopeExtensions
Inheritance
System.Object
ServiceScopeExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public static class ServiceScopeExtensions
Methods
Resolve(IServiceScope, Type)
resolve an instance for the given type from the dependency injection container. will throw if unresolvable.
Declaration
public static object Resolve(this IServiceScope scope, Type typeOfService)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceScope | scope | |
System.Type | typeOfService | the type of the service to resolve |
Returns
Type | Description |
---|---|
System.Object |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if requested service cannot be resolved |
Resolve<TService>(IServiceScope)
resolve an instance for the given type from the dependency injection container. will throw if unresolvable.
Declaration
public static TService Resolve<TService>(this IServiceScope scope)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceScope | scope |
Returns
Type | Description |
---|---|
TService |
Type Parameters
Name | Description |
---|---|
TService | the type of the service to resolve |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if requested service cannot be resolved |
TryResolve(IServiceScope, Type)
try to resolve an instance for the given type from the dependency injection container. will return null if unresolvable.
Declaration
public static object TryResolve(this IServiceScope scope, Type typeOfService)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceScope | scope | |
System.Type | typeOfService | the type of the service to resolve |
Returns
Type | Description |
---|---|
System.Object |
TryResolve<TService>(IServiceScope)
try to resolve an instance for the given type from the dependency injection container. will return null if unresolvable.
Declaration
public static TService TryResolve<TService>(this IServiceScope scope)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceScope | scope |
Returns
Type | Description |
---|---|
TService |
Type Parameters
Name | Description |
---|---|
TService | the type of the service to resolve |