/// <summary>
/// Returns true if the resolver is able to satisfy the specified dependency.
/// </summary>
/// <param name = "context">Creation context, which is a resolver itself</param>
/// <param name = "contextHandlerResolver">Parent resolver</param>
/// <param name = "model">Model of the component that is requesting the dependency</param>
/// <param name = "dependency">The dependency model</param>
/// <returns>
/// <c>true</c>
/// if the dependency can be satisfied</returns>
public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
{
// 1 - check for the dependency on CreationContext, if present
if (context != null && context.CanResolve(context, contextHandlerResolver, model, dependency))
{
return true;
}
// 2 - check with the model's handler, if not the same as the parent resolver
var handler = kernel.GetHandler(model.Name);
if (handler != null && handler != contextHandlerResolver && handler.CanResolve(context, contextHandlerResolver, model, dependency))
{
return true;
}
// 3 - check within parent resolver, if present
if (contextHandlerResolver != null && contextHandlerResolver.CanResolve(context, contextHandlerResolver, model, dependency))
{
return true;
}
// 4 - check within subresolvers
if(subResolvers.Count > 0)
{
if (subResolvers.Any(s => s.CanResolve(context, contextHandlerResolver, model, dependency)))
{
return true;
}
}
// 5 - normal flow, checking against the kernel
if (dependency.DependencyType == DependencyType.Service ||
dependency.DependencyType == DependencyType.ServiceOverride)
{
return CanResolveServiceDependency(context, model, dependency);
}
return CanResolveParameterDependency(model, dependency);
}