public SwitchStatement VisitSwitchStatement(SwitchStatement node)
        {
            theSwitch = node;
			CheckAndModifyCondition();
            ChangeCasesLabel();
            return node;
        }
        public void FixCases(SwitchStatement theSwitch)
        {
            DefaultCase defaultCase = theSwitch.Cases.LastOrDefault() as DefaultCase;
            StatementType defaultCaseStatementType = StatementType.None;
            string defaultCaseGotoLabel = null;
            if (defaultCase != null && !TryGetSimpleCaseStatementType(defaultCase, out defaultCaseStatementType, out defaultCaseGotoLabel))
            {
                return;
            }

            HashSet<SwitchCase> casesToRemove = new HashSet<SwitchCase>();
            List<SwitchCase> allCases = new List<SwitchCase>(theSwitch.Cases);
            foreach (SwitchCase @case in allCases)
            {
                if (@case == defaultCase)
                {
                    break;
                }

                if (@case.Body == null)
                {
                    casesToRemove.Add(@case);
                    continue;
                }

                StatementType caseStatementType;
                string caseGotoLabel;
                if (TryGetSimpleCaseStatementType(@case, out caseStatementType, out caseGotoLabel))
                {
                    if (defaultCase != null)
                    {
                        if (defaultCaseStatementType == caseStatementType && defaultCaseGotoLabel == caseGotoLabel)
                        {
                            casesToRemove.Add(@case);
                            break;
                        }
                    }
                    else
                    {
                        if (caseStatementType == StatementType.Break)
                        {
                            casesToRemove.Add(@case);
                            break;
                        }
                    }
                }

                casesToRemove.Clear();
            }

            if (casesToRemove.Count > 0)
            {
                theSwitch.Cases = allCases.Where(@case => !casesToRemove.Contains(@case));
            }
        }
        public override ICodeNode VisitSwitchStatement(SwitchStatement node)
        {
            node.Condition = (Expression)Visit(node.Condition);
            foreach (SwitchCase @case in node.Cases)
            {
                if (@case is ConditionCase)
                {
                    ConditionCase conditionCase = @case as ConditionCase;
                    if (NeedsCast(conditionCase.Condition.ExpressionType, node.Condition.ExpressionType))
                    {
                        if (conditionCase.Condition is LiteralExpression)
                        {
							conditionCase.Condition = EnumHelper.GetEnumExpression(node.Condition.ExpressionType.Resolve(),
													(conditionCase.Condition as LiteralExpression), typeSystem);
                        }
                        else
                        {
                            conditionCase.Condition = new CastExpression(conditionCase.Condition, node.Condition.ExpressionType, null);
                        }
                    }
                }
            }
            node = (SwitchStatement)base.VisitSwitchStatement(node);
            return node;
        }
 public override void VisitSwitchStatement(SwitchStatement node)
 {
     return;
 }
 public override ICodeNode VisitSwitchStatement(SwitchStatement node)
 {
     fixSwitchCasesStep.FixCases(node);
     return base.VisitSwitchStatement(fixSwitchConditionStep.VisitSwitchStatement(node));
 }
        public override void VisitSwitchStatement(SwitchStatement node)
        {
            loopStates.Push(StatementState.Switch);
            WriteKeyword(KeyWordWriter.Switch);
            WriteSpace();
            WriteKeyword(KeyWordWriter.Case);
            WriteSpace();

            Visit(node.Condition);

            WriteLine();
            WriteBlock(() => VisitVBSwitchCases(node.Cases), "");

            WriteEndBlock(KeyWordWriter.Switch);
            loopStates.Pop();
        }
		public override void VisitSwitchStatement(SwitchStatement node)
		{
			TryProcessConditionStatement(node);

			states.Push(Step.Expression);
			Visit(node.Condition);
			states.Pop();

			Visit(node.Cases);
		}
        /// <summary>
        /// Resolves the type of the switch variable.
        /// </summary>
        /// <param name="switchStatement">The switch statement.</param>
        /// <returns>Returns TypeReference to the type of the switch variable.</returns>
        private TypeReference GetSwitchType(SwitchStatement switchStatement)
        {
            /// switchStatement.Cases.First() without LINQ.
            ConditionCase cc = null;
            IEnumerable<SwitchCase> cases = switchStatement.Cases;
            foreach (SwitchCase @case in cases)
            {
                if (@case is ConditionCase)
                {
                    cc = @case as ConditionCase;
                    break;
                }
            }

            LiteralExpression condition = cc.Condition as LiteralExpression;
            if (condition == null)
            {
                throw new NotSupportedException("Case should have literal condition.");
            }

            TypeReference result = condition.ExpressionType;
            return result;
        }
        public override void VisitSwitchStatement(SwitchStatement node)
        {
            WriteKeyword(KeyWordWriter.Switch);

            WriteSpace();

            WriteToken("(");
            Visit(node.Condition);
            WriteToken(")");
            WriteLine();

            WriteBlock(() =>
                            {
                                Visit(node.Cases);
                                WriteLine();
                            }
            , "");
        }
 public virtual void VisitSwitchStatement(SwitchStatement node)
 {
     Visit(node.Condition);
     Visit(node.Cases);
 }