IDbDependencyResolver.GetService(Type, Object) IDbDependencyResolver.GetService(Type, Object) Method

Definition

Attempts to resolve a dependency for a given contract type and optionally a given key. If the resolver cannot resolve the dependency then it must return null and not throw. This allows resolvers to be used in a Chain of Responsibility pattern such that multiple resolvers can be asked to resolve a dependency until one finally does.

public object GetService (Type type, object key);
abstract member GetService : Type * obj -> obj

Parameters

type
Type Type

The interface or abstract base class that defines the dependency to be resolved. The returned object is expected to be an instance of this type.

key
Object Object

Optionally, the key of the dependency to be resolved. This may be null for dependencies that are not differentiated by key.

Returns

The resolved dependency, which must be an instance of the given contract type, or null if the dependency could not be resolved.

Applies to