Beispiel #1
0
        public static NewExpression New(Type type, string constructorName, object arguments)
        {
            var             result          = GetParametersAndArguments(arguments);
            ConstructorInfo constructorInfo = null;

            try
            {
                constructorInfo = type.GetConstructor(result.Item1.Select(c => c.ParameterType).ToArray());
            }
            catch
            {
            }

            if (constructorInfo == null || constructorInfo is FickleConstructorInfo)
            {
                constructorInfo = new FickleConstructorInfo(type, constructorName, result.Item1);
            }

            return(Expression.New(constructorInfo, result.Item2));
        }
Beispiel #2
0
        public static NewExpression New(Type type, string constructorName, object arguments)
        {
            var result = GetParametersAndArguments(arguments);
            ConstructorInfo constructorInfo = null;

            try
            {
                constructorInfo = type.GetConstructor(result.Item1.Select(c => c.ParameterType).ToArray());
            }
            catch
            {
            }

            if (constructorInfo == null || constructorInfo is FickleConstructorInfo)
            {
                constructorInfo = new FickleConstructorInfo(type, constructorName, result.Item1);
            }

            return Expression.New(constructorInfo, result.Item2);
        }