protected override Expression VisitConstructor(ConstructorCallSite callSite, ParameterExpression provider)
        {
            var parameters = callSite.ConstructorInfo.GetParameters();

            return(Expression.New(
                       callSite.ConstructorInfo,
                       callSite.ParameterCallSites.Select((c, index) =>
                                                          Expression.Convert(VisitCallSite(c, provider), parameters[index].ParameterType))));
        }
        protected override Type VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
        {
            Type result = null;

            foreach (var parameterCallSite in constructorCallSite.ParameterCallSites)
            {
                var scoped = VisitCallSite(parameterCallSite, state);
                if (result == null)
                {
                    result = scoped;
                }
            }
            return(result);
        }
Exemple #3
0
        protected override object VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
        {
            object[] parameterValues = new object[constructorCallSite.ParameterCallSites.Length];
            for (var index = 0; index < parameterValues.Length; index++)
            {
                parameterValues[index] = VisitCallSite(constructorCallSite.ParameterCallSites[index], provider);
            }

            try {
                return(constructorCallSite.ConstructorInfo.Invoke(parameterValues));
            }
            catch (Exception ex) when(ex.InnerException != null)
            {
                ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
                throw;
            }
        }
Exemple #4
0
 protected abstract TResult VisitConstructor(ConstructorCallSite constructorCallSite, TArgument argument);