/*----------------------------------------------------------------------------------------*/
		/// <summary>
		/// Creates an injection directive for the specified method.
		/// </summary>
		/// <param name="binding">The binding.</param>
		/// <param name="method">The method to create the directive for.</param>
		/// <returns>The created directive.</returns>
		public MethodInjectionDirective Create(IBinding binding, MethodInfo method)
		{
			var directive = new MethodInjectionDirective(method);
			CreateArgumentsForMethod(binding, method).Each(directive.Arguments.Add);

			return directive;
		}
        /*----------------------------------------------------------------------------------------*/
        private static object[] ResolveArguments(IContext context, MethodInjectionDirective directive)
        {
            var contextFactory = context.Binding.Components.ContextFactory;
            var converter      = context.Binding.Components.Converter;

            var arguments = new object[directive.Arguments.Count];

            int index = 0;

            foreach (Argument argument in directive.Arguments)
            {
                // Create a new context in which the parameter's value will be activated.
                IContext injectionContext = contextFactory.CreateChild(context,
                                                                       directive.Member, argument.Target, argument.Optional);

                // Resolve the value to inject for the parameter.
                object value = argument.Resolver.Resolve(context, injectionContext);

                // Convert the value if necessary.
                if (!converter.Convert(value, argument.Target.Type, out value))
                {
                    throw new ActivationException(ExceptionFormatter.CouldNotConvertValueForInjection(context, argument.Target, value));
                }

                arguments[index] = value;
                index++;
            }

            return(arguments);
        }
		/*----------------------------------------------------------------------------------------*/
		private static object[] ResolveArguments(IContext context, MethodInjectionDirective directive)
		{
			var contextFactory = context.Binding.Components.ContextFactory;
			var converter = context.Binding.Components.Converter;

			var arguments = new object[directive.Arguments.Count];

			int index = 0;
			foreach (Argument argument in directive.Arguments)
			{
				// Create a new context in which the parameter's value will be activated.
				IContext injectionContext = contextFactory.CreateChild(context,
					directive.Member, argument.Target, argument.Optional);

				// Resolve the value to inject for the parameter.
				object value = argument.Resolver.Resolve(context, injectionContext);

				// Convert the value if necessary.
				if (!converter.Convert(value, argument.Target.Type, out value))
					throw new ActivationException(ExceptionFormatter.CouldNotConvertValueForInjection(context, argument.Target, value));

				arguments[index] = value;
				index++;
			}

			return arguments;
		}
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Creates an injection directive for the specified method.
        /// </summary>
        /// <param name="binding">The binding.</param>
        /// <param name="method">The method to create the directive for.</param>
        /// <returns>The created directive.</returns>
        public MethodInjectionDirective Create(IBinding binding, MethodInfo method)
        {
            var directive = new MethodInjectionDirective(method);

            CreateArgumentsForMethod(binding, method).Each(directive.Arguments.Add);

            return(directive);
        }
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Adds an injection directive related to the specified member to the specified activation plan.
        /// </summary>
        /// <param name="binding">The binding that points at the type being inspected.</param>
        /// <param name="type">The type that is being inspected.</param>
        /// <param name="plan">The activation plan to add the directive to.</param>
        /// <param name="member">The member to create a directive for.</param>
        protected override void AddInjectionDirective(IBinding binding, Type type, IActivationPlan plan, MethodInfo member)
        {
            MethodInjectionDirective directive = binding.Components.DirectiveFactory.Create(binding, member);

            plan.Directives.Add(directive);
        }