ResolverOverride
During resolution, types derived from ResolverOverride are used to provide dependency values that override those resolved from the container.
Problem
public abstract class ResolverOverride
{
. . .
public virtual ResolveDelegate<TContext> GetResolver<TContext>(Type type)
where TContext : IResolveContext
{
// Resolver factory code here
}
. . .
}
The original design was to require a GetResolver call with the required Type, and if it matched, the resolver was returned. Calling the resolver returned the appropriate value. The override instance was deciding if it held the appropriate value and if it matched the required type. In version 5.x, this logic was moved into the container, making this approach obsolete. But, it is still uses two method calls to get the value.
Solution
The ResolverOverride class no longer implements method GetResolver. Instead it implements IResolve interface directly and provides held value in one step.
ResolverOverride
During resolution, types derived from
ResolverOverrideare used to provide dependency values that override those resolved from the container.Problem
The original design was to require a
GetResolvercall with the requiredType,and if it matched, the resolver was returned. Calling the resolver returned the appropriate value. The override instance was deciding if it held the appropriate value and if it matched the required type. In version 5.x, this logic was moved into the container, making this approach obsolete. But, it is still uses two method calls to get the value.Solution
The
ResolverOverrideclass no longer implements methodGetResolver. Instead it implementsIResolveinterface directly and provides held value in one step.