Beispiel #1
0
        private static MemberDeclarationSyntax GetMatchMethod(DiscriminatedUnionContext <StructDiscriminatedUnionCase> context)
        {
            var match = GeneratorHelpers.CreateMatchMethod(context.Cases.Cast <IDiscriminatedUnionCase>(), context.MatchGenericParameter)
                        .WithModifiers(
                TokenList(
                    Token(SyntaxKind.PublicKeyword)
                    )
                )
                        .WithBody(GetMatchBlock(context.Cases));

            return(match);
        }
        private static MemberDeclarationSyntax GetAbstractMatchMethod(DiscriminatedUnionContext <DiscriminatedUnionCase> context)
        {
            var match = GeneratorHelpers.CreateMatchMethod(context.Cases.Cast <IDiscriminatedUnionCase>(), context.MatchGenericParameter)
                        .WithModifiers(
                TokenList(
                    Token(SyntaxKind.PublicKeyword),
                    Token(SyntaxKind.AbstractKeyword)
                    )
                )
                        .WithSemicolonToken(Token(SyntaxKind.SemicolonToken));

            return(match);
        }
Beispiel #3
0
        private static MemberDeclarationSyntax GetMatchImplementation(
            DiscriminatedUnionContext <DiscriminatedUnionCase> context,
            DiscriminatedUnionCase currentCase)
        {
            var match = GeneratorHelpers.CreateMatchMethod(context.Cases.Cast <IDiscriminatedUnionCase>(), context.MatchGenericParameter)
                        .WithModifiers(
                TokenList(
                    Token(SyntaxKind.PublicKeyword),
                    Token(SyntaxKind.OverrideKeyword)
                    )
                )
                        .WithBody(GetMatchBlock(context.Cases, currentCase));

            return(match);
        }