Microsoft.Zing.Splicer.GenerateTypeChoiceHelper C# (CSharp) Method

GenerateTypeChoiceHelper() private method

private GenerateTypeChoiceHelper ( ) : void
return void
        private void GenerateTypeChoiceHelper()
        {
            TypeNode choiceHelperClass = Templates.GetTypeTemplateByName("ChoiceHelper");
            Debug.Assert(choiceHelperClass.Members[0] is Method);
            Method choiceHelperMethod = (Method)choiceHelperClass.Members[0];
            appClass.Members.Add(choiceHelperMethod);
            choiceHelperMethod.DeclaringType = appClass;

            if (choosableTypes.Count == 0)
            {
                choiceHelperMethod.Body.Statements.Add(Templates.GetStatementTemplate("ChoiceHelperEnd"));
                return;
            }

            If lastIf = null;

            foreach (DictionaryEntry de in choosableTypes)
            {
                If thisIf = (If)Templates.GetStatementTemplate("ChoiceHelperBody");
                Replacer.Replace(thisIf, "_ChoiceType", (Node)de.Key);
                Replacer.Replace(thisIf, "_ChoiceTypeChoices", (Node)de.Value);

                if (lastIf != null)
                    lastIf.FalseBlock = new Block(new StatementList(thisIf));
                else
                    choiceHelperMethod.Body.Statements.Add(thisIf);

                lastIf = thisIf;
            }

            lastIf.FalseBlock = new Block(new StatementList(Templates.GetStatementTemplate("ChoiceHelperEnd")));
        }