Interface IResolver
An IResolver enables the dependency to be resolved based on the contract type and an optional id.
This interface should not be cached in any object unless its a service level object.
Assembly: cs.temp.dll.dll
Syntax
public interface IResolver
Methods
CanResolve(Type)
Check if the dependency based on the type
type exists in the IContainer.
Declaration
bool CanResolve(Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
Examples
CanResolve(typeof(IInterface)) == true;
CanResolve(Type, Object)
Check if the dependency based on the type
type associated with the id
exists in the IContainer
Declaration
bool CanResolve(Type type, object id)
Parameters
Returns
Examples
CanResolve(typeof(IInterface), "foo") == true;
CanResolve<TContract>()
Check if the dependency based on the TContract
type exists in the
IContainer.
Declaration
bool CanResolve<TContract>()
Returns
Type Parameters
Name |
Description |
TContract |
|
Examples
CanResolve<IInterface>() == true;
CanResolve<TContract>(Object)
Check if the dependency based on the TContract
type associated with the
id
type exists in the IContainer.
Declaration
bool CanResolve<TContract>(object id)
Parameters
Type |
Name |
Description |
Object |
id |
|
Returns
Type Parameters
Name |
Description |
TContract |
|
Examples
CanResolve<IInterface>("foo") == true;
Resolve(Type)
Resolve and return the dependency based on the type
type.
Declaration
object Resolve(Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
Examples
object foo = Resolve(typeof(IInterface));
Resolve(Type, Object)
Resolve and return the dependency based on the type
type associated with the
id
.
Declaration
object Resolve(Type type, object id)
Parameters
Returns
Examples
object foo = Resolve(typeof(IInterface), "foo");
Resolve<TContract>()
Resolve and return the dependency based on the TContract
type.
Declaration
TContract Resolve<TContract>()
Returns
Type |
Description |
TContract |
|
Type Parameters
Name |
Description |
TContract |
|
Examples
IInterface foo = Resolve<IInterface>();
Resolve<TContract>(Object)
Resolve and return the dependency based on the TContract
type associated with
the id
.
Declaration
TContract Resolve<TContract>(object id)
Parameters
Type |
Name |
Description |
Object |
id |
|
Returns
Type |
Description |
TContract |
|
Type Parameters
Name |
Description |
TContract |
|
Examples
IInterface foo = Resolve<IInterface>("foo");
ResolveAll(Type)
Resolve and return all the dependencies based on the type
type.
Declaration
object[] ResolveAll(Type type)
Parameters
Type |
Name |
Description |
Type |
type |
|
Returns
Examples
object[] foos = ResolveAll(typeof(IInterface));
ResolveAll(Type, IEnumerable<Object>)
Resolve and return all the dependencies based on the type
type associated with
the ids
.
Declaration
object[] ResolveAll(Type type, IEnumerable<object> ids)
Parameters
Type |
Name |
Description |
Type |
type |
|
IEnumerable<Object> |
ids |
|
Returns
Examples
object[] foos = ResolveAll(typeof(IInterface), ids);
ResolveAll<TContract>()
Resolve and return all the dependencies based on the TContract
type.
Declaration
TContract[] ResolveAll<TContract>()
Returns
Type |
Description |
TContract[] |
|
Type Parameters
Name |
Description |
TContract |
|
Examples
IInterface[] foos = ResolveAll<IInterface>();
ResolveAll<TContract>(IEnumerable<Object>)
Resolve and return all the dependencies based on the TContract
type associated with
the ids
.
Declaration
TContract[] ResolveAll<TContract>(IEnumerable<object> ids)
Parameters
Type |
Name |
Description |
IEnumerable<Object> |
ids |
|
Returns
Type |
Description |
TContract[] |
|
Type Parameters
Name |
Description |
TContract |
|
Examples
IInterface[] foos = ResolveAll<IInterface>(ids);
ResolveAll<TContract>(Predicate<TContract>)
Resolve and return all the dependencies that satisfied the predicate
.
Declaration
TContract[] ResolveAll<TContract>(Predicate<TContract> predicate)
Parameters
Type |
Name |
Description |
Predicate<TContract> |
predicate |
|
Returns
Type |
Description |
TContract[] |
|
Type Parameters
Name |
Description |
TContract |
|
Examples
IInterface[] foos = ResolveAll<IInterface>(item => item.GetType() == typeof(TContract));
TryResolve(Type, Object, out Object)
Try to resolve and return the dependency based on the type
associated with an
id
. If the dependency exists, the dependency would be returned via the out
value
. false and default value
would be returned otherwise.
Declaration
bool TryResolve(Type type, object id, out object value)
Parameters
Returns
TryResolve(Type, out Object)
Try to resolve and return the dependency based on the type
. If the dependency exists,
the dependency would be returned via the out value
. false and default
value
would be returned otherwise.
Declaration
bool TryResolve(Type type, out object value)
Parameters
Returns
TryResolve<TContract>(out TContract)
Try to resolve and return the dependency based on the TContract
.
If the dependency exists, the dependency would be returned via the out value
.
false and default value
would be returned otherwise.
Declaration
bool TryResolve<TContract>(out TContract value)
Parameters
Type |
Name |
Description |
TContract |
value |
|
Returns
Type Parameters
Name |
Description |
TContract |
|
TryResolve<TContract>(Object, out TContract)
Try to resolve and return the dependency based on the TContract
associated with an
id
. If the dependency exists, the dependency would be returned via the out
value
. false and default value
would be returned otherwise.
Declaration
bool TryResolve<TContract>(object id, out TContract value)
Parameters
Type |
Name |
Description |
Object |
id |
|
TContract |
value |
|
Returns
Type Parameters
Name |
Description |
TContract |
|