Пример #1
0
 private ExpressionStatementSyntax BuildAddRestClientExpressionStatement(RestClientInfo restClient)
 {
     return
         (ExpressionStatement(
              InvocationExpression(
                  MemberAccessExpression(
                      SyntaxKind.SimpleMemberAccessExpression,
                      IdentifierName(nameof(RestClientFactory)),
                      GenericName(Identifier(nameof(RestClientFactory.SetRestClient)))
                      .WithTypeArgumentList(
                          TypeArgumentList(
                              SeparatedList(
                                  new TypeSyntax[]
     {
         IdentifierName(restClient.InterfaceName),
         IdentifierName(restClient.ClassName)
     })))))));
 }
Пример #2
0
        private ClassDeclarationSyntax BuildRestClient(RestClientInfo restClient)
        {
            var interfaceDeclaration = restClient.InterfaceDeclaration;

            this.interfaceRequestInfo = new RequestInfo(interfaceDeclaration);

            var classDeclaration = ClassDeclaration(restClient.ClassName)
                                   .AddModifiers(Token(SyntaxKind.InternalKeyword))
                                   .AddModifiers(Token(SyntaxKind.SealedKeyword))
                                   .WithTypeParameterList(interfaceDeclaration.TypeParameterList)
                                   .WithConstraintClauses(interfaceDeclaration.ConstraintClauses)
                                   .AddMembers(this.ImplementMethods(interfaceDeclaration.Members))
                                   .WithBaseList(BaseList(SeparatedList <BaseTypeSyntax>(new[]
            {
                SimpleBaseType(IdentifierName(nameof(RestClientBase))),
                SimpleBaseType(interfaceDeclaration.GetTypeSyntax())
            })));

            return(classDeclaration);
        }