예제 #1
0
        internal override void Execute(RuleExecution execution)
        {
            Type expressionType          = execution.Validation.ExpressionInfo(this.assignStatement.Left).ExpressionType;
            Type operandType             = execution.Validation.ExpressionInfo(this.assignStatement.Right).ExpressionType;
            RuleExpressionResult result  = RuleExpressionWalker.Evaluate(execution, this.assignStatement.Left);
            RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, this.assignStatement.Right);

            result.Value = Executor.AdjustType(operandType, result2.Value, expressionType);
        }
예제 #2
0
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            CodeIndexerExpression      expression2 = (CodeIndexerExpression)expression;
            RulePropertyExpressionInfo info        = execution.Validation.ExpressionInfo(expression2) as RulePropertyExpressionInfo;

            if (info == null)
            {
                InvalidOperationException exception = new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ExpressionNotValidated, new object[0]));
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            PropertyInfo propertyInfo = info.PropertyInfo;
            object       targetObject = RuleExpressionWalker.Evaluate(execution, expression2.TargetObject).Value;

            if (targetObject == null)
            {
                RuleEvaluationException exception2 = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.TargetEvaluatedNullIndexer, new object[0]));
                exception2.Data["ErrorObject"] = expression2;
                throw exception2;
            }
            int count = expression2.Indices.Count;

            ParameterInfo[] indexParameters  = propertyInfo.GetIndexParameters();
            object[]        indexerArguments = new object[indexParameters.Length];
            int             length           = indexParameters.Length;

            if (info.NeedsParamsExpansion)
            {
                length--;
            }
            int index = 0;

            while (index < length)
            {
                Type expressionType         = execution.Validation.ExpressionInfo(expression2.Indices[index]).ExpressionType;
                RuleExpressionResult result = RuleExpressionWalker.Evaluate(execution, expression2.Indices[index]);
                indexerArguments[index] = Executor.AdjustType(expressionType, result.Value, indexParameters[index].ParameterType);
                index++;
            }
            if (length < count)
            {
                ParameterInfo info3         = indexParameters[length];
                Type          parameterType = info3.ParameterType;
                Type          elementType   = parameterType.GetElementType();
                Array         array         = (Array)parameterType.InvokeMember(parameterType.Name, BindingFlags.CreateInstance, null, null, new object[] { count - index }, CultureInfo.CurrentCulture);
                while (index < count)
                {
                    Type operandType             = execution.Validation.ExpressionInfo(expression2.Indices[index]).ExpressionType;
                    RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, expression2.Indices[index]);
                    array.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), (int)(index - length));
                    index++;
                }
                indexerArguments[length] = array;
            }
            return(new RulePropertyResult(propertyInfo, targetObject, indexerArguments));
        }
        internal override void Execute(RuleExecution execution)
        {
            Type leftType  = execution.Validation.ExpressionInfo(assignStatement.Left).ExpressionType;
            Type rightType = execution.Validation.ExpressionInfo(assignStatement.Right).ExpressionType;

            RuleExpressionResult leftResult  = RuleExpressionWalker.Evaluate(execution, assignStatement.Left);
            RuleExpressionResult rightResult = RuleExpressionWalker.Evaluate(execution, assignStatement.Right);

            leftResult.Value = Executor.AdjustType(rightType, rightResult.Value, leftType);
        }
예제 #4
0
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            CodeArrayCreateExpression expression2 = (CodeArrayCreateExpression)expression;

            if (expression2.CreateType == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(Messages.NullTypeType);
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            RuleExpressionInfo info = execution.Validation.ExpressionInfo(expression2);

            if (expression2 == null)
            {
                InvalidOperationException exception2 = new InvalidOperationException(Messages.ExpressionNotValidated);
                exception2.Data["ErrorObject"] = expression2;
                throw exception2;
            }
            Type elementType = info.ExpressionType.GetElementType();
            int  length      = 0;

            if (expression2.SizeExpression != null)
            {
                Type expressionType         = execution.Validation.ExpressionInfo(expression2.SizeExpression).ExpressionType;
                RuleExpressionResult result = RuleExpressionWalker.Evaluate(execution, expression2.SizeExpression);
                if (expressionType == typeof(int))
                {
                    length = (int)result.Value;
                }
                else if (expressionType == typeof(long))
                {
                    length = (int)((long)result.Value);
                }
                else if (expressionType == typeof(uint))
                {
                    length = (int)((uint)result.Value);
                }
                else if (expressionType == typeof(ulong))
                {
                    length = (int)((ulong)result.Value);
                }
            }
            else if (expression2.Size != 0)
            {
                length = expression2.Size;
            }
            else
            {
                length = expression2.Initializers.Count;
            }
            Array literal = Array.CreateInstance(elementType, length);

            if (expression2.Initializers != null)
            {
                for (int i = 0; i < expression2.Initializers.Count; i++)
                {
                    CodeExpression       expression3 = expression2.Initializers[i];
                    Type                 operandType = execution.Validation.ExpressionInfo(expression3).ExpressionType;
                    RuleExpressionResult result2     = RuleExpressionWalker.Evaluate(execution, expression3);
                    literal.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), i);
                }
            }
            return(new RuleLiteralResult(literal));
        }
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            object obj2;
            CodeObjectCreateExpression expression2 = (CodeObjectCreateExpression)expression;

            if (expression2.CreateType == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(Messages.NullTypeType);
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            RuleExpressionInfo info = execution.Validation.ExpressionInfo(expression2);

            if (info == null)
            {
                InvalidOperationException exception2 = new InvalidOperationException(Messages.ExpressionNotValidated);
                exception2.Data["ErrorObject"] = expression2;
                throw exception2;
            }
            RuleConstructorExpressionInfo info2 = info as RuleConstructorExpressionInfo;

            if (info2 == null)
            {
                return(new RuleLiteralResult(Activator.CreateInstance(info.ExpressionType)));
            }
            ConstructorInfo constructorInfo = info2.ConstructorInfo;

            object[] parameters = null;
            RuleExpressionResult[] resultArray = null;
            if ((expression2.Parameters != null) && (expression2.Parameters.Count > 0))
            {
                int             count     = expression2.Parameters.Count;
                ParameterInfo[] infoArray = constructorInfo.GetParameters();
                parameters = new object[infoArray.Length];
                int length = infoArray.Length;
                if (info2.NeedsParamsExpansion)
                {
                    length--;
                }
                int index = 0;
                while (index < length)
                {
                    Type expressionType                 = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                    RuleExpressionResult    result      = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                    CodeDirectionExpression expression3 = expression2.Parameters[index] as CodeDirectionExpression;
                    if ((expression3 != null) && ((expression3.Direction == FieldDirection.Ref) || (expression3.Direction == FieldDirection.Out)))
                    {
                        if (resultArray == null)
                        {
                            resultArray = new RuleExpressionResult[count];
                        }
                        resultArray[index] = result;
                    }
                    parameters[index] = Executor.AdjustType(expressionType, result.Value, infoArray[index].ParameterType);
                    index++;
                }
                if (length < count)
                {
                    ParameterInfo info4       = infoArray[length];
                    Type          elementType = info4.ParameterType.GetElementType();
                    Array         array       = Array.CreateInstance(elementType, (int)(count - index));
                    while (index < count)
                    {
                        Type operandType             = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                        RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                        array.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), (int)(index - length));
                        index++;
                    }
                    parameters[length] = array;
                }
            }
            try
            {
                obj2 = constructorInfo.Invoke(parameters);
            }
            catch (TargetInvocationException exception3)
            {
                if (exception3.InnerException == null)
                {
                    throw;
                }
                throw new TargetInvocationException(string.Format(CultureInfo.CurrentCulture, Messages.Error_ConstructorInvoke, new object[] { RuleDecompiler.DecompileType(info2.ExpressionType), exception3.InnerException.Message }), exception3.InnerException);
            }
            if (resultArray != null)
            {
                for (int i = 0; i < expression2.Parameters.Count; i++)
                {
                    if (resultArray[i] != null)
                    {
                        resultArray[i].Value = parameters[i];
                    }
                }
            }
            return(new RuleLiteralResult(obj2));
        }
예제 #6
0
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            object obj3;
            CodeMethodInvokeExpression expression2 = (CodeMethodInvokeExpression)expression;
            object obj2 = RuleExpressionWalker.Evaluate(execution, expression2.Method.TargetObject).Value;
            RuleMethodInvokeExpressionInfo info = execution.Validation.ExpressionInfo(expression2) as RuleMethodInvokeExpressionInfo;

            if (info == null)
            {
                InvalidOperationException exception = new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ExpressionNotValidated, new object[0]));
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            MethodInfo methodInfo = info.MethodInfo;

            if (!methodInfo.IsStatic && (obj2 == null))
            {
                RuleEvaluationException exception2 = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.TargetEvaluatedNullMethod, new object[] { expression2.Method.MethodName }));
                exception2.Data["ErrorObject"] = expression2;
                throw exception2;
            }
            object[] parameters = null;
            RuleExpressionResult[] resultArray = null;
            if ((expression2.Parameters != null) && (expression2.Parameters.Count > 0))
            {
                int             count     = expression2.Parameters.Count;
                ParameterInfo[] infoArray = methodInfo.GetParameters();
                parameters = new object[infoArray.Length];
                int length = infoArray.Length;
                if (info.NeedsParamsExpansion)
                {
                    length--;
                }
                int index = 0;
                while (index < length)
                {
                    Type expressionType                 = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                    RuleExpressionResult    result      = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                    CodeDirectionExpression expression3 = expression2.Parameters[index] as CodeDirectionExpression;
                    if ((expression3 != null) && ((expression3.Direction == FieldDirection.Ref) || (expression3.Direction == FieldDirection.Out)))
                    {
                        if (resultArray == null)
                        {
                            resultArray = new RuleExpressionResult[expression2.Parameters.Count];
                        }
                        resultArray[index] = result;
                        if (expression3.Direction != FieldDirection.Out)
                        {
                            parameters[index] = Executor.AdjustType(expressionType, result.Value, infoArray[index].ParameterType);
                        }
                    }
                    else
                    {
                        parameters[index] = Executor.AdjustType(expressionType, result.Value, infoArray[index].ParameterType);
                    }
                    index++;
                }
                if (length < count)
                {
                    ParameterInfo info3         = infoArray[length];
                    Type          parameterType = info3.ParameterType;
                    Type          elementType   = parameterType.GetElementType();
                    Array         array         = (Array)parameterType.InvokeMember(parameterType.Name, BindingFlags.CreateInstance, null, null, new object[] { count - index }, CultureInfo.CurrentCulture);
                    while (index < count)
                    {
                        Type operandType             = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                        RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                        array.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), (int)(index - length));
                        index++;
                    }
                    parameters[length] = array;
                }
            }
            try
            {
                obj3 = methodInfo.Invoke(obj2, parameters);
            }
            catch (TargetInvocationException exception3)
            {
                if (exception3.InnerException == null)
                {
                    throw;
                }
                throw new TargetInvocationException(string.Format(CultureInfo.CurrentCulture, Messages.Error_MethodInvoke, new object[] { RuleDecompiler.DecompileType(methodInfo.ReflectedType), methodInfo.Name, exception3.InnerException.Message }), exception3.InnerException);
            }
            if (resultArray != null)
            {
                for (int i = 0; i < expression2.Parameters.Count; i++)
                {
                    if (resultArray[i] != null)
                    {
                        resultArray[i].Value = parameters[i];
                    }
                }
            }
            return(new RuleLiteralResult(obj3));
        }
예제 #7
0
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            CodeObjectCreateExpression createExpression = (CodeObjectCreateExpression)expression;

            if (createExpression.CreateType == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(Messages.NullTypeType);
                exception.Data[RuleUserDataKeys.ErrorObject] = createExpression;
                throw exception;
            }

            RuleExpressionInfo expressionInfo = execution.Validation.ExpressionInfo(createExpression);
            if (expressionInfo == null)  // Oops, someone forgot to validate.
            {
                InvalidOperationException exception = new InvalidOperationException(Messages.ExpressionNotValidated);
                exception.Data[RuleUserDataKeys.ErrorObject] = createExpression;
                throw exception;
            }

            RuleConstructorExpressionInfo createExpressionInfo = expressionInfo as RuleConstructorExpressionInfo;
            if (createExpressionInfo == null)
            {
                // it's just a regular RuleExpressionInfo, which means this is a value-type with no parameters
                return new RuleLiteralResult(Activator.CreateInstance(expressionInfo.ExpressionType));
            }

            ConstructorInfo constructor = createExpressionInfo.ConstructorInfo;
            object[] arguments = null;
            RuleExpressionResult[] outArgumentResults = null;

            if (createExpression.Parameters != null && createExpression.Parameters.Count > 0)
            {
                int actualArgCount = createExpression.Parameters.Count;
                ParameterInfo[] parmInfos = constructor.GetParameters();

                arguments = new object[parmInfos.Length];

                int numFixedParameters = parmInfos.Length;
                if (createExpressionInfo.NeedsParamsExpansion)
                    numFixedParameters -= 1;

                int i;

                // Evaluate the fixed portion of the parameter list.
                for (i = 0; i < numFixedParameters; ++i)
                {
                    Type argType = execution.Validation.ExpressionInfo(createExpression.Parameters[i]).ExpressionType;
                    RuleExpressionResult argResult = RuleExpressionWalker.Evaluate(execution, createExpression.Parameters[i]);

                    // Special procesing of direction expressions to keep track of out arguments (& ref).
                    CodeDirectionExpression direction = createExpression.Parameters[i] as CodeDirectionExpression;
                    if (direction != null && (direction.Direction == FieldDirection.Ref || direction.Direction == FieldDirection.Out))
                    {
                        // lazy creation of fieldsToSet
                        if (outArgumentResults == null)
                            outArgumentResults = new RuleExpressionResult[actualArgCount];
                        // keep track of this out expression so we can set it later
                        outArgumentResults[i] = argResult;
                    }

                    arguments[i] = Executor.AdjustType(argType, argResult.Value, parmInfos[i].ParameterType);
                }

                if (numFixedParameters < actualArgCount)
                {
                    // This target method had a params array, and we are calling it with an
                    // expanded parameter list.  E.g.,
                    //      void foo(int x, params string[] y)
                    // with the invocation:
                    //      foo(5, "crud", "kreeble", "glorp")
                    // We need to translate this to:
                    //      foo(5, new string[] { "crud", "kreeble", "glorp" })

                    ParameterInfo lastParamInfo = parmInfos[numFixedParameters];

                    Type arrayType = lastParamInfo.ParameterType;
                    System.Diagnostics.Debug.Assert(arrayType.IsArray);
                    Type elementType = arrayType.GetElementType();

                    Array paramsArray = Array.CreateInstance(elementType, actualArgCount - i);
                    for (; i < actualArgCount; ++i)
                    {
                        Type argType = execution.Validation.ExpressionInfo(createExpression.Parameters[i]).ExpressionType;
                        RuleExpressionResult argResult = RuleExpressionWalker.Evaluate(execution, createExpression.Parameters[i]);
                        paramsArray.SetValue(Executor.AdjustType(argType, argResult.Value, elementType), i - numFixedParameters);
                    }

                    arguments[numFixedParameters] = paramsArray;
                }
            }

            object result;
            try
            {
                result = constructor.Invoke(arguments);
            }
            catch (TargetInvocationException e)
            {
                // if there is no inner exception, leave it untouched
                if (e.InnerException == null)
                    throw;
                string message = string.Format(CultureInfo.CurrentCulture,
                    Messages.Error_ConstructorInvoke,
                    RuleDecompiler.DecompileType(createExpressionInfo.ExpressionType),
                    e.InnerException.Message);
                throw new TargetInvocationException(message, e.InnerException);
            }

            // any out/ref parameters that need to be assigned?
            if (outArgumentResults != null)
            {
                for (int i = 0; i < createExpression.Parameters.Count; ++i)
                {
                    if (outArgumentResults[i] != null)
                        outArgumentResults[i].Value = arguments[i];
                }
            }
            return new RuleLiteralResult(result);
        }
예제 #8
0
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            string message;

            CodeMethodInvokeExpression invokeExpr = (CodeMethodInvokeExpression)expression;

            object target = RuleExpressionWalker.Evaluate(execution, invokeExpr.Method.TargetObject).Value;

            RuleMethodInvokeExpressionInfo invokeExprInfo = execution.Validation.ExpressionInfo(invokeExpr) as RuleMethodInvokeExpressionInfo;
            if (invokeExprInfo == null)  // Oops, someone forgot to validate.
            {
                message = string.Format(CultureInfo.CurrentCulture, Messages.ExpressionNotValidated);
                InvalidOperationException exception = new InvalidOperationException(message);
                exception.Data[RuleUserDataKeys.ErrorObject] = invokeExpr;
                throw exception;
            }

            MethodInfo mi = invokeExprInfo.MethodInfo;

            if (!mi.IsStatic && target == null)
            {
                message = string.Format(CultureInfo.CurrentCulture, Messages.TargetEvaluatedNullMethod, invokeExpr.Method.MethodName);
                RuleEvaluationException exception = new RuleEvaluationException(message);
                exception.Data[RuleUserDataKeys.ErrorObject] = invokeExpr;
                throw exception;
            }

            object[] arguments = null;
            RuleExpressionResult[] outArgumentResults = null;

            if (invokeExpr.Parameters != null && invokeExpr.Parameters.Count > 0)
            {
                int actualArgCount = invokeExpr.Parameters.Count;

                ParameterInfo[] parmInfos = mi.GetParameters();

                arguments = new object[parmInfos.Length];

                int numFixedParameters = parmInfos.Length;
                if (invokeExprInfo.NeedsParamsExpansion)
                    numFixedParameters -= 1;

                int i;

                // Evaluate the fixed portion of the parameter list.
                for (i = 0; i < numFixedParameters; ++i)
                {
                    Type argType = execution.Validation.ExpressionInfo(invokeExpr.Parameters[i]).ExpressionType;
                    RuleExpressionResult argResult = RuleExpressionWalker.Evaluate(execution, invokeExpr.Parameters[i]);

                    // Special procesing of direction expressions to keep track of out arguments (& ref).
                    CodeDirectionExpression direction = invokeExpr.Parameters[i] as CodeDirectionExpression;
                    if (direction != null && (direction.Direction == FieldDirection.Ref || direction.Direction == FieldDirection.Out))
                    {
                        // lazy creation of fieldsToSet
                        if (outArgumentResults == null)
                            outArgumentResults = new RuleExpressionResult[invokeExpr.Parameters.Count];
                        // keep track of this out expression so we can set it later
                        outArgumentResults[i] = argResult;

                        // don't evaluate out arguments
                        if (direction.Direction != FieldDirection.Out)
                            arguments[i] = Executor.AdjustType(argType, argResult.Value, parmInfos[i].ParameterType);
                    }
                    else
                    {
                        // treat as in
                        arguments[i] = Executor.AdjustType(argType, argResult.Value, parmInfos[i].ParameterType);
                    }
                }

                if (numFixedParameters < actualArgCount)
                {
                    // This target method had a params array, and we are calling it with an
                    // expanded parameter list.  E.g.,
                    //      void foo(int x, params string[] y)
                    // with the invocation:
                    //      foo(5, "crud", "kreeble", "glorp")
                    // We need to translate this to:
                    //      foo(5, new string[] { "crud", "kreeble", "glorp" })

                    ParameterInfo lastParamInfo = parmInfos[numFixedParameters];

                    Type arrayType = lastParamInfo.ParameterType;
                    System.Diagnostics.Debug.Assert(arrayType.IsArray);
                    Type elementType = arrayType.GetElementType();

                    Array paramsArray = (Array)arrayType.InvokeMember(arrayType.Name, BindingFlags.CreateInstance, null, null, new object[] { actualArgCount - i }, CultureInfo.CurrentCulture);
                    for (; i < actualArgCount; ++i)
                    {
                        Type argType = execution.Validation.ExpressionInfo(invokeExpr.Parameters[i]).ExpressionType;
                        RuleExpressionResult argResult = RuleExpressionWalker.Evaluate(execution, invokeExpr.Parameters[i]);
                        paramsArray.SetValue(Executor.AdjustType(argType, argResult.Value, elementType), i - numFixedParameters);
                    }

                    arguments[numFixedParameters] = paramsArray;
                }
            }

            object result;
            try
            {
                result = mi.Invoke(target, arguments);
            }
            catch (TargetInvocationException e)
            {
                // if there is no inner exception, leave it untouched
                if (e.InnerException == null)
                    throw;
                message = string.Format(CultureInfo.CurrentCulture, Messages.Error_MethodInvoke,
                    RuleDecompiler.DecompileType(mi.ReflectedType), mi.Name, e.InnerException.Message);
                throw new TargetInvocationException(message, e.InnerException);
            }

            // any out/ref parameters that need to be assigned?
            if (outArgumentResults != null)
            {
                for (int i = 0; i < invokeExpr.Parameters.Count; ++i)
                {
                    if (outArgumentResults[i] != null)
                        outArgumentResults[i].Value = arguments[i];
                }
            }

            return new RuleLiteralResult(result);
        }
 internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
 {
     object obj3;
     CodeMethodInvokeExpression expression2 = (CodeMethodInvokeExpression) expression;
     object obj2 = RuleExpressionWalker.Evaluate(execution, expression2.Method.TargetObject).Value;
     RuleMethodInvokeExpressionInfo info = execution.Validation.ExpressionInfo(expression2) as RuleMethodInvokeExpressionInfo;
     if (info == null)
     {
         InvalidOperationException exception = new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ExpressionNotValidated, new object[0]));
         exception.Data["ErrorObject"] = expression2;
         throw exception;
     }
     MethodInfo methodInfo = info.MethodInfo;
     if (!methodInfo.IsStatic && (obj2 == null))
     {
         RuleEvaluationException exception2 = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.TargetEvaluatedNullMethod, new object[] { expression2.Method.MethodName }));
         exception2.Data["ErrorObject"] = expression2;
         throw exception2;
     }
     object[] parameters = null;
     RuleExpressionResult[] resultArray = null;
     if ((expression2.Parameters != null) && (expression2.Parameters.Count > 0))
     {
         int count = expression2.Parameters.Count;
         ParameterInfo[] infoArray = methodInfo.GetParameters();
         parameters = new object[infoArray.Length];
         int length = infoArray.Length;
         if (info.NeedsParamsExpansion)
         {
             length--;
         }
         int index = 0;
         while (index < length)
         {
             Type expressionType = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
             RuleExpressionResult result = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
             CodeDirectionExpression expression3 = expression2.Parameters[index] as CodeDirectionExpression;
             if ((expression3 != null) && ((expression3.Direction == FieldDirection.Ref) || (expression3.Direction == FieldDirection.Out)))
             {
                 if (resultArray == null)
                 {
                     resultArray = new RuleExpressionResult[expression2.Parameters.Count];
                 }
                 resultArray[index] = result;
                 if (expression3.Direction != FieldDirection.Out)
                 {
                     parameters[index] = Executor.AdjustType(expressionType, result.Value, infoArray[index].ParameterType);
                 }
             }
             else
             {
                 parameters[index] = Executor.AdjustType(expressionType, result.Value, infoArray[index].ParameterType);
             }
             index++;
         }
         if (length < count)
         {
             ParameterInfo info3 = infoArray[length];
             Type parameterType = info3.ParameterType;
             Type elementType = parameterType.GetElementType();
             Array array = (Array) parameterType.InvokeMember(parameterType.Name, BindingFlags.CreateInstance, null, null, new object[] { count - index }, CultureInfo.CurrentCulture);
             while (index < count)
             {
                 Type operandType = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                 RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                 array.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), (int) (index - length));
                 index++;
             }
             parameters[length] = array;
         }
     }
     try
     {
         obj3 = methodInfo.Invoke(obj2, parameters);
     }
     catch (TargetInvocationException exception3)
     {
         if (exception3.InnerException == null)
         {
             throw;
         }
         throw new TargetInvocationException(string.Format(CultureInfo.CurrentCulture, Messages.Error_MethodInvoke, new object[] { RuleDecompiler.DecompileType(methodInfo.ReflectedType), methodInfo.Name, exception3.InnerException.Message }), exception3.InnerException);
     }
     if (resultArray != null)
     {
         for (int i = 0; i < expression2.Parameters.Count; i++)
         {
             if (resultArray[i] != null)
             {
                 resultArray[i].Value = parameters[i];
             }
         }
     }
     return new RuleLiteralResult(obj3);
 }
 internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
 {
     object obj2;
     CodeObjectCreateExpression expression2 = (CodeObjectCreateExpression) expression;
     if (expression2.CreateType == null)
     {
         RuleEvaluationException exception = new RuleEvaluationException(Messages.NullTypeType);
         exception.Data["ErrorObject"] = expression2;
         throw exception;
     }
     RuleExpressionInfo info = execution.Validation.ExpressionInfo(expression2);
     if (info == null)
     {
         InvalidOperationException exception2 = new InvalidOperationException(Messages.ExpressionNotValidated);
         exception2.Data["ErrorObject"] = expression2;
         throw exception2;
     }
     RuleConstructorExpressionInfo info2 = info as RuleConstructorExpressionInfo;
     if (info2 == null)
     {
         return new RuleLiteralResult(Activator.CreateInstance(info.ExpressionType));
     }
     ConstructorInfo constructorInfo = info2.ConstructorInfo;
     object[] parameters = null;
     RuleExpressionResult[] resultArray = null;
     if ((expression2.Parameters != null) && (expression2.Parameters.Count > 0))
     {
         int count = expression2.Parameters.Count;
         ParameterInfo[] infoArray = constructorInfo.GetParameters();
         parameters = new object[infoArray.Length];
         int length = infoArray.Length;
         if (info2.NeedsParamsExpansion)
         {
             length--;
         }
         int index = 0;
         while (index < length)
         {
             Type expressionType = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
             RuleExpressionResult result = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
             CodeDirectionExpression expression3 = expression2.Parameters[index] as CodeDirectionExpression;
             if ((expression3 != null) && ((expression3.Direction == FieldDirection.Ref) || (expression3.Direction == FieldDirection.Out)))
             {
                 if (resultArray == null)
                 {
                     resultArray = new RuleExpressionResult[count];
                 }
                 resultArray[index] = result;
             }
             parameters[index] = Executor.AdjustType(expressionType, result.Value, infoArray[index].ParameterType);
             index++;
         }
         if (length < count)
         {
             ParameterInfo info4 = infoArray[length];
             Type elementType = info4.ParameterType.GetElementType();
             Array array = Array.CreateInstance(elementType, (int) (count - index));
             while (index < count)
             {
                 Type operandType = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                 RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                 array.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), (int) (index - length));
                 index++;
             }
             parameters[length] = array;
         }
     }
     try
     {
         obj2 = constructorInfo.Invoke(parameters);
     }
     catch (TargetInvocationException exception3)
     {
         if (exception3.InnerException == null)
         {
             throw;
         }
         throw new TargetInvocationException(string.Format(CultureInfo.CurrentCulture, Messages.Error_ConstructorInvoke, new object[] { RuleDecompiler.DecompileType(info2.ExpressionType), exception3.InnerException.Message }), exception3.InnerException);
     }
     if (resultArray != null)
     {
         for (int i = 0; i < expression2.Parameters.Count; i++)
         {
             if (resultArray[i] != null)
             {
                 resultArray[i].Value = parameters[i];
             }
         }
     }
     return new RuleLiteralResult(obj2);
 }