internal SeparatedSyntaxList <ArgumentSyntax> GenerateListPagedSpecificationRequest(List <AttributesWithInfo> attributesWithInfo, ArgumentFilterConstantsHelpers argumentFilterConstantsHelpers, bool pagedSpec = false) { var arguments = new List <SyntaxNodeOrToken>(); if (pagedSpec) { arguments.AddRange(new SyntaxNodeOrToken[] { Argument( BinaryExpression( SyntaxKind.MultiplyExpression, MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, IdentifierName("request"), IdentifierName("PageIndex")), MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, IdentifierName("request"), IdentifierName("PageSize")))), Token(SyntaxKind.CommaToken), Argument( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, IdentifierName("request"), IdentifierName("PageSize"))), Token(SyntaxKind.CommaToken) }); } attributesWithInfo.ForEach(x => x.Arguments.Where(y => y.Any() && !y.Contains("INCLUDE")).ToList().ForEach(y => { arguments.Add( Argument( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, IdentifierName("request"), IdentifierName($"{x.PropertyIdentifier}{argumentFilterConstantsHelpers.GetArgumentSufix(y)}")))); arguments.Add( Token(SyntaxKind.CommaToken)); } )); // Remove last comma arguments.RemoveAt(arguments.Count - 1); return(SeparatedList <ArgumentSyntax>(arguments)); }
public SyntaxList <MemberDeclarationSyntax> GenerateRequestOrDtoClassMemeberProperties(string endpoint, List <PropertiesWithInfo> propertiesWithInfo, string modelClassName = null, List <AttributesWithInfo> attributesWithInfo = null, ArgumentFilterConstantsHelpers argumentFilterConstantsHelpers = null) { var list = new List <MemberDeclarationSyntax>(); if (endpoint.Equals("Create") || endpoint.Equals("Update") || endpoint.Equals("Dto")) { propertiesWithInfo.Where(x => x.Method.Equals(EndpointMethods[endpoint])).ToList().ForEach(x => list.Add( PropertyDeclaration( IdentifierName(x.Type), Identifier(x.Identifier)) .WithModifiers( TokenList( Token(SyntaxKind.PublicKeyword))) .WithAccessorList( AccessorList( List( new AccessorDeclarationSyntax[] { AccessorDeclaration( SyntaxKind.GetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)), AccessorDeclaration( SyntaxKind.SetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)) }))))); } if (endpoint.Equals("GetById") || endpoint.Equals("Delete")) { list.Add(PropertyDeclaration( PredefinedType( Token(SyntaxKind.IntKeyword)), Identifier($"{modelClassName}Id")) .WithModifiers( TokenList( Token(SyntaxKind.PublicKeyword))) .WithAccessorList( AccessorList( List( new AccessorDeclarationSyntax[] { AccessorDeclaration( SyntaxKind.GetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)), AccessorDeclaration( SyntaxKind.SetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)) })))); } if (endpoint.Equals("ListPaged")) { list.Add( PropertyDeclaration( IdentifierName("int"), Identifier($"PageIndex")) .WithModifiers( TokenList( Token(SyntaxKind.PublicKeyword))) .WithAccessorList( AccessorList( List( new AccessorDeclarationSyntax[] { AccessorDeclaration( SyntaxKind.GetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)), AccessorDeclaration( SyntaxKind.SetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)) })))); list.Add( PropertyDeclaration( IdentifierName("int"), Identifier($"PageSize")) .WithModifiers( TokenList( Token(SyntaxKind.PublicKeyword))) .WithAccessorList( AccessorList( List( new AccessorDeclarationSyntax[] { AccessorDeclaration( SyntaxKind.GetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)), AccessorDeclaration( SyntaxKind.SetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)) })))); attributesWithInfo.ForEach(x => x.Arguments.Where(y => y.Any() && !y.Contains("INCLUDE")).ToList().ForEach(y => list.Add( PropertyDeclaration( IdentifierName(x.Type), Identifier($"{x.PropertyIdentifier}{argumentFilterConstantsHelpers.GetArgumentSufix(y)}")) .WithModifiers( TokenList( Token(SyntaxKind.PublicKeyword))) .WithAccessorList( AccessorList( List( new AccessorDeclarationSyntax[] { AccessorDeclaration( SyntaxKind.GetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)), AccessorDeclaration( SyntaxKind.SetAccessorDeclaration) .WithSemicolonToken( Token(SyntaxKind.SemicolonToken)) })))) )); } return(List(list)); }