Example #1
0
 public static PropertyDeclarationSyntax DeclareAutoProperty(
     this TypeSyntax type,
     string identifier)
 {
     return(SyntaxFactory.PropertyDeclaration(type.AppendWhitespace <TypeSyntax>(), SyntaxFactory.Identifier(identifier).AppendWhitespace()).WithModifiers(SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword).AppendWhitespace())).WithAccessorList(SyntaxFactory.AccessorList(SyntaxFactory.List <AccessorDeclarationSyntax>((IEnumerable <AccessorDeclarationSyntax>) new AccessorDeclarationSyntax[2]
     {
         SyntaxEx.PropertyAccessor(PropertyAccessorType.Get),
         SyntaxEx.PropertyAccessor(PropertyAccessorType.Set)
     }))).AppendNewLine <PropertyDeclarationSyntax>(true));
 }
Example #2
0
 public static PropertyDeclarationSyntax DeclareAutoProperty(TypeSyntax type, string identifier)
 {
     return(SyntaxFactory.PropertyDeclaration(
                type.AppendWhitespace(),
                SyntaxFactory.Identifier(identifier).AppendWhitespace())
            .WithModifiers(
                SyntaxFactory.TokenList(
                    SyntaxFactory.Token(SyntaxKind.PublicKeyword).AppendWhitespace()
                    ))
            .WithAccessorList(
                SyntaxFactory.AccessorList(
                    SyntaxFactory.List <AccessorDeclarationSyntax>(
                        new AccessorDeclarationSyntax[] {
         PropertyAccessor(PropertyAccessorType.Get),
         PropertyAccessor(PropertyAccessorType.Set)
     })))
            .AppendNewLine());
 }