private void BindBuildPlan(ConcreteBuildPlan buildPlan)
 {
     var parameters = buildPlan.Constructor.GetParameters();
     for (var i = 0; i < parameters.Length; i++)
     {
         IList<IBuildPlan> bp;
         if (!_serviceMappings.TryGetValue(parameters[i].ParameterType, out bp))
             throw new InvalidOperationException(string.Format("Failed to find service {0}.",
                                                               parameters[i].ParameterType));
         buildPlan.AddConstructorPlan(i, bp[0]);
     }
 }
        private void BindBuildPlan(ConcreteBuildPlan buildPlan)
        {
            var parameters = buildPlan.Constructor.GetParameters();
            for (var i = 0; i < parameters.Length; i++)
            {
                var p = parameters[i];
                IBuildPlan parameterBp;

                if (p.ParameterType.IsGenericType && p.ParameterType.GetGenericTypeDefinition() == typeof(IEnumerable<>) && p.ParameterType.GetGenericArguments().Length == 1)
                {
                    var serviceType = p.ParameterType.GetGenericArguments()[0];

                    IList<IBuildPlan> bp;
                    if (!_serviceMappings.TryGetValue(serviceType, out bp))
                    {
                        parameterBp = new EmptyListBuildPlan(serviceType);
                        // empty lists are fine.
                        //throw new InvalidOperationException(string.Format("Failed to find service {0}.",
                        //                                                  parameters[i].ParameterType));
                    }
                    else
                        parameterBp = new CompositeBuildPlan(serviceType, bp.ToArray());
                }
                else
                {

                    IList<IBuildPlan> bp;
                    if (!_serviceMappings.TryGetValue(parameters[i].ParameterType, out bp))
                        throw new InvalidOperationException(string.Format("Failed to find service {0}.",
                                                                          parameters[i].ParameterType));

                    parameterBp = bp[0];
                }

                buildPlan.AddConstructorPlan(i, parameterBp);
            }
        }