예제 #1
0
        public override void WriteTo(CodeWriter writer)
        {
            foreach (var item in Case)
            {
                if (item.Mask)
                {
                    using (writer.NewBlock())
                    {
                        writer.AddCommentLine(item.Comment);
                        item.Block.WriteTo(writer);
                    }
                    return;
                }
            }

            for (int i = 0; i < Case.Count; i++)
            {
                writer.NewLine();
                writer.Write(i == 0 ? "if" : "else if");
                writer.Write(" (");
                Case[i].Condition.WriteToWithCast(writer, ProjectConverter.CppTypeName_Bool);
                writer.Write(")");
                using (writer.NewBlock())
                {
                    writer.AddCommentLine(Case[i].Comment);
                    Case[i].Block.WriteTo(writer);
                }
            }
            writer.NewLine();
            writer.Write("else");
            using (writer.NewBlock())
            {
                DefaultBlock.WriteTo(writer);
            }
        }