private bool IsDelegateOperationStatement(Statement statement, string operationName,
            out Expression newValueHolder, out Expression oldValueHolder)
        {
            newValueHolder = null;
            oldValueHolder = null;

            if (!statement.IsAssignmentStatement())
            {
                return false;
            }

            BinaryExpression assignExpression = (statement as ExpressionStatement).Expression as BinaryExpression;
            if (assignExpression.Right.CodeNodeType != CodeNodeType.CastExpression ||
                (assignExpression.Right as CastExpression).Expression.CodeNodeType != CodeNodeType.MethodInvocationExpression)
            {
                return false;
            }

            MethodInvocationExpression methodInvokeExpr = (assignExpression.Right as CastExpression).Expression as MethodInvocationExpression;
            if (methodInvokeExpr.Arguments.Count != 2 || methodInvokeExpr.MethodExpression.Method.HasThis ||
                methodInvokeExpr.MethodExpression.Method.DeclaringType.FullName != "System.Delegate" || methodInvokeExpr.MethodExpression.Method.Name != operationName)
            {
                return false;
            }

            if (methodInvokeExpr.Arguments[1].CodeNodeType != CodeNodeType.ArgumentReferenceExpression)
            {
                return false;
            }

            newValueHolder = assignExpression.Left;
            oldValueHolder = methodInvokeExpr.Arguments[0];
            return true;
        }
        private int CheckNewArrayInitializationAndSize(Statement statement, VariableReference arrayVariable)
        {
            if (!statement.IsAssignmentStatement())
            {
                throw new Exception(InvalidStatementExceptionString);
            }

            BinaryExpression arrayInitialization = (statement as ExpressionStatement).Expression as BinaryExpression;

            if (arrayInitialization.Left.CodeNodeType != CodeNodeType.VariableReferenceExpression ||
                (arrayInitialization.Left as VariableReferenceExpression).Variable != arrayVariable)
            {
                throw new Exception(InvalidStatementExceptionString);
            }

            if (arrayInitialization.Right.CodeNodeType != CodeNodeType.ArrayCreationExpression ||
                (arrayInitialization.Right as ArrayCreationExpression).Dimensions.Count != 1 ||
                (arrayInitialization.Right as ArrayCreationExpression).Dimensions[0].CodeNodeType != CodeNodeType.LiteralExpression)
            {
                throw new Exception(InvalidStatementExceptionString);
            }

            return Convert.ToInt32(((arrayInitialization.Right as ArrayCreationExpression).Dimensions[0] as LiteralExpression).Value);
        }