Class DependencyLocatorExtensions
- Namespace
- LfrlAnvil.Dependencies.Extensions
- Assembly
- LfrlAnvil.Dependencies.dll
Contains IDependencyLocator extension methods.
public static class DependencyLocatorExtensions
- Inheritance
-
DependencyLocatorExtensions
- Inherited Members
Methods
Resolve(IDependencyLocator, Type)
Resolves a dependency of the provided type
.
[Pure]
public static object Resolve(this IDependencyLocator locator, Type type)
Parameters
locator
IDependencyLocatorSource dependency locator.
type
TypeType to resolve.
Returns
- object
Instance of the resolved dependency.
Exceptions
- CircularDependencyReferenceException
When a circular dependency reference has been detected.
- InvalidDependencyCastException
When the resolved result is not an instance of the provided
type
.- MissingDependencyException
When the provided
type
could not be resolved.
Resolve<T>(IDependencyLocator)
Resolves a dependency of the provided type.
[Pure]
public static T Resolve<T>(this IDependencyLocator locator) where T : class
Parameters
locator
IDependencyLocatorSource dependency locator.
Returns
- T
Instance of the resolved dependency.
Type Parameters
T
Type to resolve.
Exceptions
- CircularDependencyReferenceException
When a circular dependency reference has been detected.
- InvalidDependencyCastException
When the resolved result is not an instance of the provided type.
- MissingDependencyException
When the provided type could not be resolved.
TryResolve(IDependencyLocator, Type)
Attempts to resolve a dependency of the provided type
.
[Pure]
public static object? TryResolve(this IDependencyLocator locator, Type type)
Parameters
locator
IDependencyLocatorSource dependency locator.
type
TypeType to resolve.
Returns
- object
Instance of the resolved dependency or null when the resolution has failed.
Exceptions
- CircularDependencyReferenceException
When a circular dependency reference has been detected.
- InvalidDependencyCastException
When the resolved result is not an instance of the provided
type
.
TryResolve<T>(IDependencyLocator)
Attempts to resolve a dependency of the provided type.
[Pure]
public static T? TryResolve<T>(this IDependencyLocator locator) where T : class
Parameters
locator
IDependencyLocatorSource dependency locator.
Returns
- T
Instance of the resolved dependency or null when the resolution has failed.
Type Parameters
T
Type to resolve.
Exceptions
- CircularDependencyReferenceException
When a circular dependency reference has been detected.
- InvalidDependencyCastException
When the resolved result is not an instance of the provided type.