Example #1
0
        private ParameterDictionary <DependencyData> BuildConstructorParameters(Type implementationType,
                                                                                ConstructorInfo constructor)
        {
            // NOTE: We used to use a LINQ query here (which is cleaner code), but we reverted back to using
            // a foreach statement to clean up the stack trace, since this is a very common code path to
            // show up in the stack trace and preventing showing up the Enumerable and Buffer`1 calls here
            // makes it easier for developers (and maintainers) to read the stack trace.
            var parameters = new ParameterDictionary <DependencyData>();

            foreach (ParameterInfo parameter in constructor.GetParameters())
            {
                var              consumer   = new InjectionConsumerInfo(parameter);
                Expression       expression = this.GetPlaceHolderFor(parameter);
                InstanceProducer producer   = null;

                if (expression == null)
                {
                    producer   = this.Container.Options.GetInstanceProducerFor(consumer);
                    expression = producer.BuildExpression();
                }

                parameters.Add(parameter, new DependencyData(parameter, expression, producer));
            }

            return(parameters);
        }