Пример #1
0
        public static ClassDeclarationSyntax CreateAsPublicStatic(string classTypeName)
        {
            if (classTypeName == null)
            {
                throw new ArgumentNullException(nameof(classTypeName));
            }

            return(SyntaxFactory.ClassDeclaration(classTypeName)
                   .AddModifiers(SyntaxTokenFactory.PublicKeyword(), SyntaxTokenFactory.StaticKeyword()));
        }
        public static InterfaceDeclarationSyntax Create(string interfaceTypeName)
        {
            if (interfaceTypeName == null)
            {
                throw new ArgumentNullException(nameof(interfaceTypeName));
            }

            return(SyntaxFactory.InterfaceDeclaration(interfaceTypeName)
                   .AddModifiers(SyntaxTokenFactory.PublicKeyword()));
        }
Пример #3
0
        public static ClassDeclarationSyntax CreateWithInheritClassType(string classTypeName, string inheritClassTypeName)
        {
            if (classTypeName == null)
            {
                throw new ArgumentNullException(nameof(classTypeName));
            }

            return(SyntaxFactory.ClassDeclaration(classTypeName)
                   .AddModifiers(SyntaxTokenFactory.PublicKeyword())
                   .AddBaseListTypes(SyntaxFactory.SimpleBaseType(SyntaxFactory.ParseTypeName(inheritClassTypeName))));
        }
Пример #4
0
        public static SyntaxTokenList PublicKeyword(bool withLeadingLineFeed = false, bool withTrailingSpace = true)
        {
            if (withLeadingLineFeed)
            {
                return(SyntaxFactory.TokenList(
                           SyntaxTokenFactory.CarriageReturnLineFeed(),
                           SyntaxTokenFactory.PublicKeyword(withTrailingSpace)));
            }

            return(SyntaxFactory.TokenList(
                       SyntaxTokenFactory.PublicKeyword(withTrailingSpace)));
        }
Пример #5
0
        public static ClassDeclarationSyntax CreateWithInterface(string classTypeName, string interfaceTypeName)
        {
            if (classTypeName == null)
            {
                throw new ArgumentNullException(nameof(classTypeName));
            }

            return(SyntaxFactory.ClassDeclaration(classTypeName)
                   .AddModifiers(SyntaxTokenFactory.PublicKeyword())
                   .WithBaseList(
                       SyntaxFactory.BaseList(
                           SyntaxFactory.SingletonSeparatedList <BaseTypeSyntax>(
                               SyntaxFactory.SimpleBaseType(
                                   SyntaxFactory.IdentifierName(interfaceTypeName))))));
        }
Пример #6
0
        public static ClassDeclarationSyntax CreateWithInheritClassAndInterface(string classTypeName, string inheritClassTypeName, string interfaceTypeName)
        {
            if (classTypeName == null)
            {
                throw new ArgumentNullException(nameof(classTypeName));
            }

            if (inheritClassTypeName == null)
            {
                throw new ArgumentNullException(nameof(inheritClassTypeName));
            }

            if (interfaceTypeName == null)
            {
                throw new ArgumentNullException(nameof(interfaceTypeName));
            }

            return(SyntaxFactory.ClassDeclaration(classTypeName)
                   .AddModifiers(SyntaxTokenFactory.PublicKeyword())
                   .WithBaseList(SyntaxBaseListFactory.CreateTwoSimpleBaseTypes(inheritClassTypeName, interfaceTypeName)));
        }