/// <summary>
		///   Resolves the component(s) from given kernel.
		/// </summary>
		/// <param name = "kernel"></param>
		/// <param name = "scope"></param>
		/// <returns>Resolved component(s).</returns>
		public virtual object Resolve(IKernelInternal kernel, IReleasePolicy scope)
		{
			if (ComponentName != null && kernel.LoadHandlerByKey(ComponentName, ComponentType, AdditionalArguments) != null)
			{
				return kernel.Resolve(ComponentName, ComponentType, AdditionalArguments, scope);
			}
			return kernel.Resolve(ComponentType, AdditionalArguments, scope);
		}
		private bool LoadByName(IKernelInternal kernel)
		{
			if (componentName == null)
			{
				return false;
			}
			return fallbackToResolveByTypeIfNameNotFound == false || kernel.LoadHandlerByKey(componentName, componentType, additionalArguments) != null;
		}
 /// <summary>
 ///   Resolves the component(s) from given kernel.
 /// </summary>
 /// <param name = "kernel"></param>
 /// <param name = "scope"></param>
 /// <returns>Resolved component(s).</returns>
 public virtual object Resolve(IKernelInternal kernel, IReleasePolicy scope)
 {
     if (ComponentName != null && kernel.LoadHandlerByKey(ComponentName, ComponentType, AdditionalArguments) != null)
     {
         return(kernel.Resolve(ComponentName, ComponentType, AdditionalArguments, scope));
     }
     return(kernel.Resolve(ComponentType, AdditionalArguments, scope));
 }
 private bool LoadByName(IKernelInternal kernel)
 {
     if (componentName == null)
     {
         return(false);
     }
     return(fallbackToResolveByTypeIfNameNotFound == false || kernel.LoadHandlerByKey(componentName, componentType, additionalArguments) != null);
 }
        protected virtual object ResolveCore(CreationContext context, ComponentModel model, DependencyModel dependency)
        {
            var parameter = dependency.Parameter;

            if (parameter != null)
            {
                if (dependency.Reference == null)
                {
                    converter.Context.Push(model, context);

                    try
                    {
                        if (parameter.Value != null || parameter.ConfigValue == null)
                        {
                            return(converter.PerformConversion(parameter.Value, dependency.TargetItemType));
                        }
                        else
                        {
                            return(converter.PerformConversion(parameter.ConfigValue, dependency.TargetItemType));
                        }
                    }
                    catch (ConverterException e)
                    {
                        throw new DependencyResolverException(string.Format("Could not convert parameter '{0}' to type '{1}'.", parameter.Name, dependency.TargetItemType.Name), e);
                    }
                    finally
                    {
                        converter.Context.Pop();
                    }
                }
            }

            if (typeof(IKernel).IsAssignableFrom(dependency.TargetItemType))
            {
                return(kernel);
            }
            IHandler handler;

            if (dependency.Reference != null)
            {
                handler = kernel.LoadHandlerByKey(dependency.Reference, dependency.TargetItemType, context.AdditionalArguments);
            }
            else
            {
                try
                {
                    handler = TryGetHandlerFromKernel(dependency, context);
                }
                catch (HandlerException exception)
                {
                    if (dependency.HasDefaultValue)
                    {
                        return(dependency.DefaultValue);
                    }
                    throw new DependencyResolverException(
                              string.Format(
                                  "Missing dependency.{2}Component {0} has a dependency on {1}, which could not be resolved.{2}Make sure the dependency is correctly registered in the container as a service, or provided as inline argument.",
                                  model.Name,
                                  dependency.TargetItemType,
                                  Environment.NewLine),
                              exception);
                }

                if (handler == null)
                {
                    if (dependency.HasDefaultValue)
                    {
                        return(dependency.DefaultValue);
                    }
                    throw new DependencyResolverException(
                              string.Format(
                                  "Cycle detected in configuration.{2}Component {0} has a dependency on {1}, but it doesn't provide an override.{2}You must provide an override if a component has a dependency on a service that it - itself - provides.",
                                  model.Name,
                                  dependency.TargetItemType,
                                  Environment.NewLine));
                }
            }
            if (handler == null)
            {
                return(null);
            }

            context = RebuildContextForParameter(context, dependency.TargetItemType);

            return(handler.Resolve(context));
        }