示例#1
0
        private bool HasAnyComponentInValidState(Type service, DependencyModel dependency, CreationContext context)
        {
            IHandler firstHandler;

            if (context != null && context.IsResolving)
            {
                firstHandler = kernel.LoadHandlerByType(dependency.DependencyKey, service, context.AdditionalArguments);
            }
            else
            {
                firstHandler = kernel.GetHandler(service);
            }
            if (firstHandler == null)
            {
                return(false);
            }
            if (context == null || firstHandler.IsBeingResolvedInContext(context) == false)
            {
                if (IsHandlerInValidState(firstHandler))
                {
                    return(true);
                }
            }

            var handlers = kernel.GetHandlers(service);

            return(handlers.Where(handler => handler.IsBeingResolvedInContext(context) == false)
                   .Any(IsHandlerInValidState));
        }