示例#1
0
        private TypeDeclarationSyntax BuildStruct(DiscriminatedUnionContext <StructDiscriminatedUnionCase> context)
        {
            var casesClass = CreateEmptyCasesPartialClass();

            casesClass = casesClass.WithMembers(List(context.Cases.SelectMany(c => c.Members)));
            var members = context.Members.Add(casesClass);

            return(context.WithMembers(List(members)).GeneratedPartialClass);
        }
示例#2
0
        private TypeDeclarationSyntax BuildClass(DiscriminatedUnionContext <DiscriminatedUnionCase> context)
        {
            var casesPartialClass = CreateEmptyCasesPartialClass();

            return(context.WithMembers(
                       List(
                           context.Members.Add(
                               casesPartialClass.WithMembers(
                                   List(
                                       context.Cases
                                       .Select(c => c.GeneratedPartialClass.WithMembers(List(c.Members)))
                                       .Cast <MemberDeclarationSyntax>()
                                       )
                                   )
                               )
                           )
                       )
                   .GeneratedPartialClass);
        }