예제 #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));
        }
 public object Resolve(Type serviceType)
 {
     if (_kernel.LoadHandlerByType(null, serviceType, null) != null)
     {
         return(_kernel.Resolve(serviceType));
     }
     return(null);
 }
예제 #3
0
 public object GetService(Type serviceType)
 {
     if (kernel.LoadHandlerByType(null, serviceType, null) == null)
     {
         return(kernel.Resolve(serviceType));
     }
     return(null);
 }