├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── actions │ ├── build │ │ └── action.yml │ ├── push │ │ └── action.yml │ ├── release-info │ │ └── action.yml │ ├── test-core │ │ └── action.yml │ ├── test-framework │ │ └── action.yml │ └── test-release │ │ └── action.yml ├── pull_request_template.md └── workflows │ ├── codeql-analysis.yml │ ├── notifications.yml │ ├── release-alpha.yml │ ├── release-beta.yml │ ├── release-dev.yml │ ├── release.yml │ ├── sonarcloud-analysis.yml │ ├── test-base.yml │ └── test-full.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NClient.sln ├── NClient.sln.DotSettings ├── README.md ├── Tests.slnf ├── benchmark └── NClient.Benchmark.Client │ ├── .run │ └── NClient.Benchmark.run.xml │ ├── Clients │ ├── Flurl │ │ ├── FlurlHttpClientFactory.cs │ │ ├── FlurlSystemJsonSerializer.cs │ │ └── TestFlurlClient.cs │ ├── HttpClient │ │ └── TestHttpClient.cs │ ├── NClient │ │ └── TestNClient.cs │ ├── Refit │ │ └── TestRefitClient.cs │ ├── RestEase │ │ └── TestRestEase.cs │ └── RestSharp │ │ └── TestRestSharpClient.cs │ ├── Dtos │ ├── Dto.cs │ └── DtoJsonContext.cs │ ├── Helpers │ ├── DtoProvider.cs │ └── IdProvider.cs │ ├── HttpMock │ ├── MockDtoHttpMessageHandlerBuilder.cs │ └── MockIdHttpMessageHandlerBuilder.cs │ ├── JsonClient │ ├── JsonClient.cs │ └── JsonClientBenchmark.cs │ ├── JsonHttpResponseClient │ ├── JsonHttpResponseClient.cs │ └── JsonHttpResponseClientBenchmark.cs │ ├── JsonSourceGeneratorClient │ └── JsonSourceGeneratorClientBenchmark.cs │ ├── NClient.Benchmark.Client.csproj │ ├── PrimitiveClient │ ├── PrimitiveClient.cs │ └── PrimitiveClientBenchmark.cs │ ├── PrimitiveHttpResponseClient │ ├── PrimitiveHttpResponseClient.cs │ └── PrimitiveHttpResponseClientBenchmark.cs │ └── Program.cs ├── jetbrains.png ├── logo.png ├── sandbox ├── NClient.Sandbox.Client │ ├── ClientHandlers │ │ └── LoggingClientHandler.cs │ ├── NClient.Sandbox.Client.csproj │ └── Program.cs ├── NClient.Sandbox.FileService.Facade │ ├── IFileClient.cs │ ├── IFileController.cs │ └── NClient.Sandbox.FileService.Facade.csproj ├── NClient.Sandbox.FileService │ ├── Controllers │ │ ├── FileController.cs │ │ └── NativeFileController.cs │ ├── Files │ │ ├── Image.jpg │ │ └── TextFile.txt │ ├── NClient.Sandbox.FileService.csproj │ ├── NClient.Sandbox.FileService.csproj.DotSettings │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── NClient.Sandbox.ProxyService.Facade │ ├── Dto │ │ ├── WeatherForecastDto.cs │ │ └── WeatherForecastFilter.cs │ ├── IWeatherForecastClient.cs │ ├── IWeatherForecastController.cs │ └── NClient.Sandbox.ProxyService.Facade.csproj ├── NClient.Sandbox.ProxyService │ ├── Clients │ │ └── IThirdPartyWeatherForecastClient.cs │ ├── Controllers │ │ ├── NativeWeatherForecastController.cs │ │ └── WeatherForecastController.cs │ ├── NClient.Sandbox.ProxyService.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ └── appsettings.json └── NClient.Sandbox.ThirdPartyService │ ├── Controllers │ └── WeatherForecastController.cs │ ├── Models │ └── WeatherForecast.cs │ ├── NClient.Sandbox.ThirdPartyService.csproj │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── src ├── NClient.CodeGeneration │ ├── NClient.CodeGeneration.Abstractions │ │ ├── Enums │ │ │ └── SerializeType.cs │ │ ├── FacadeGenerationSettings.cs │ │ ├── INClientFacadeGenerator.cs │ │ ├── INClientFacadeGeneratorProvider.cs │ │ └── NClient.CodeGeneration.Abstractions.csproj │ └── NClient.CodeGeneration.Facades.NSwag │ │ ├── CSharpFacadeGenerator.cs │ │ ├── CSharpFacadeGeneratorSettings.cs │ │ ├── FacadeTemplateFactory.cs │ │ ├── Models │ │ ├── CSharpFacadeOperationModel.cs │ │ └── CSharpFacadeTemplateModel.cs │ │ ├── NClient.CodeGeneration.Facades.NSwag.csproj │ │ ├── NSwagFacadeGenerator.cs │ │ ├── NSwagFacadeGeneratorProvider.cs │ │ └── Templates │ │ ├── Facade.Annotations.liquid │ │ ├── Facade.Method.Annotations.liquid │ │ ├── Facade.liquid │ │ └── File.liquid ├── NClient.Extensions │ └── NClient.Extensions.DependencyInjection │ │ ├── Extensions │ │ ├── AddCustomNClientExtensions.cs │ │ ├── AddCustomNClientFactoryExtensions.cs │ │ ├── AddRestNClientExtensions.cs │ │ └── AddRestNClientFactoryExtensions.cs │ │ └── NClient.Extensions.DependencyInjection.csproj ├── NClient.Providers │ ├── NClient.Providers.Api.Rest │ │ ├── Exceptions │ │ │ └── Factories │ │ │ │ ├── ClientArgumentExceptionFactory.cs │ │ │ │ ├── ClientValidationExceptionFactory.cs │ │ │ │ ├── ObjectMemberManagerExceptionFactory.cs │ │ │ │ └── ObjectToKeyValueConverterExceptionFactory.cs │ │ ├── Extensions │ │ │ └── RestApiExtensions.cs │ │ ├── Helpers │ │ │ └── FormUrlEncoder.cs │ │ ├── Models │ │ │ └── MethodParameter.cs │ │ ├── NClient.Providers.Api.Rest.csproj │ │ ├── Providers │ │ │ ├── RequestTypeProvider.cs │ │ │ ├── RouteProvider.cs │ │ │ └── RouteTemplateProvider.cs │ │ ├── RestRequestBuilder.cs │ │ └── RestRequestBuilderProvider.cs │ ├── NClient.Providers.Mapping.HttpResponses │ │ ├── Extensions │ │ │ ├── HttpResponsesExtensions.cs │ │ │ └── UseHttpResponsesExtensions.cs │ │ ├── NClient.Providers.Mapping.HttpResponses.csproj │ │ ├── Requests │ │ │ └── HttpRequest.cs │ │ ├── ResponseToHttpResponseMapper.cs │ │ ├── ResponseToHttpResponseMapperProvider.cs │ │ └── Responses │ │ │ ├── HttpResponse.cs │ │ │ └── HttpResponseWithError.cs │ ├── NClient.Providers.Mapping.LanguageExt │ │ ├── Extensions │ │ │ ├── LanguageExtExtensions.cs │ │ │ └── UseLanguageExtExtensions.cs │ │ ├── NClient.Providers.Mapping.LanguageExt.csproj │ │ ├── ResponseToEitherBuilder.cs │ │ └── ResponseToEitherBuilderProvider.cs │ ├── NClient.Providers.Resilience.Polly │ │ ├── CustomPollyResiliencePolicyProvider.cs │ │ ├── DefaultPollyResiliencePolicyProvider.cs │ │ ├── Extensions │ │ │ ├── CustomPollyFullResilienceExtensions.cs │ │ │ ├── CustomPollyIdempotentResilienceExtensions.cs │ │ │ ├── CustomPollySafeResilienceExtensions.cs │ │ │ ├── CustomUsePollyExtensions.cs │ │ │ ├── DefaultPollyFullResilienceExtensions.cs │ │ │ ├── DefaultPollyIdempotentResilienceExtensions.cs │ │ │ ├── DefaultPollySafeResilienceExtensions.cs │ │ │ └── DefaultUsePollyExtensions.cs │ │ ├── NClient.Providers.Resilience.Polly.csproj │ │ └── PollyResiliencePolicy.cs │ ├── NClient.Providers.Serialization.MessagePack │ │ ├── Enums │ │ │ └── MIMEType.cs │ │ ├── Extensions │ │ │ ├── MessagePackSerializationExtensions.cs │ │ │ └── UsingMessagePackSerializerExtensions.cs │ │ ├── MessagePackSerializer.cs │ │ ├── MessagePackSerializerProvider.cs │ │ ├── MessagePackSerializerSettings.cs │ │ └── NClient.Providers.Serialization.MessagePack.csproj │ ├── NClient.Providers.Serialization.NewtonsoftJson │ │ ├── Extensions │ │ │ ├── NewtonsoftJsonSerializationExtensions.cs │ │ │ └── UsingNewtonsoftJsonSerializationExtensions.cs │ │ ├── NClient.Providers.Serialization.NewtonsoftJson.csproj │ │ ├── NewtonsoftJsonSerializer.cs │ │ └── NewtonsoftJsonSerializerProvider.cs │ ├── NClient.Providers.Serialization.ProtobufNet │ │ ├── Extensions │ │ │ ├── ProtobufNetSerializationExtensions.cs │ │ │ └── UsingProtobufNetSerializationExtensions.cs │ │ ├── NClient.Providers.Serialization.ProtobufNet.csproj │ │ ├── ProtobufNetSerializer.cs │ │ ├── ProtobufNetSerializerProvider.cs │ │ └── ProtobufNetSerializerSettings.cs │ ├── NClient.Providers.Serialization.SystemTextJson │ │ ├── Extensions │ │ │ ├── SystemTextJsonSerializationExtensions.cs │ │ │ └── UsingSystemTextJsonSerializerExtensions.cs │ │ ├── NClient.Providers.Serialization.SystemTextJson.csproj │ │ ├── SystemTextJsonSerializer.cs │ │ └── SystemTextJsonSerializerProvider.cs │ ├── NClient.Providers.Serialization.SystemXml │ │ ├── Extensions │ │ │ ├── SystemXmlSerializationExtensions.cs │ │ │ └── UsingSystemXmlSerializationExtensions.cs │ │ ├── NClient.Providers.Serialization.SystemXml.csproj │ │ ├── SystemXmlSerializer.cs │ │ └── SystemXmlSerializerProvider.cs │ ├── NClient.Providers.Transport.RestSharp │ │ ├── Extensions │ │ │ ├── RestSharpResponseValidationExtensions.cs │ │ │ ├── RestSharpTransportExtensions.cs │ │ │ └── UseRestSharpResponseValidationExtensions.cs │ │ ├── Helpers │ │ │ ├── HttpKnownHeaderNames.cs │ │ │ └── RestSharpMethodMapper.cs │ │ ├── NClient.Providers.Transport.RestSharp.csproj │ │ ├── Resilience │ │ │ ├── DefaultRestSharpResiliencePolicySettings.cs │ │ │ └── RestSharpResiliencePolicySettings.cs │ │ ├── RestSharpResponseBuilder.cs │ │ ├── RestSharpResponseBuilderProvider.cs │ │ ├── RestSharpTransport.cs │ │ ├── RestSharpTransportProvider.cs │ │ ├── RestSharpTransportRequestBuilder.cs │ │ ├── RestSharpTransportRequestBuilderProvider.cs │ │ └── Validation │ │ │ ├── DefaultRestSharpResponseValidatorSettings.cs │ │ │ └── RestSharpResponseValidatorSettings.cs │ └── NClient.Providers.Transport.SystemNetHttp │ │ ├── AspNetCore │ │ └── QueryHelpers.cs │ │ ├── Extensions │ │ ├── SystemNetHttpResponseValidationExtensions.cs │ │ ├── SystemNetHttpTransportBuilderExtensions.cs │ │ └── UseSystemNetHttpResponseValidationExtensions.cs │ │ ├── Helpers │ │ ├── HttpResponseMessageExtensions.cs │ │ ├── LeavingOpenStreamContent.cs │ │ ├── SystemNetHttpClientFactory.cs │ │ └── SystemNetHttpMethodMapper.cs │ │ ├── Mapping │ │ ├── HttpFileContentResponseMapper.cs │ │ └── StreamContentResponseMapper.cs │ │ ├── Models │ │ ├── HeaderDictionary.cs │ │ └── HttpFileContent.cs │ │ ├── NClient.Providers.Transport.SystemNetHttp.csproj │ │ ├── Resilience │ │ ├── DefaultSystemNetHttpResiliencePolicySettings.cs │ │ └── SystemNetHttpResiliencePolicySettings.cs │ │ ├── SystemNetHttpResponseBuilder.cs │ │ ├── SystemNetHttpResponseBuilderProvider.cs │ │ ├── SystemNetHttpTransport.cs │ │ ├── SystemNetHttpTransportProvider.cs │ │ ├── SystemNetHttpTransportRequestBuilder.cs │ │ ├── SystemNetHttpTransportRequestBuilderProvider.cs │ │ └── Validation │ │ ├── DefaultSystemNetHttpResponseValidatorSettings.cs │ │ └── SystemNetHttpResponseValidatorSettings.cs ├── NClient.Tools │ └── NClient.DotNetTool │ │ ├── FacadeGenerator.cs │ │ ├── Loaders │ │ ├── FileLoader.cs │ │ ├── ILoaderFactory.cs │ │ ├── ISpecificationLoader.cs │ │ ├── LoaderFactory.cs │ │ └── NetworkLoader.cs │ │ ├── Logging │ │ ├── LogEvents.cs │ │ ├── LoggerExtensions.cs │ │ └── ToolConsoleFormatter.cs │ │ ├── NClient.DotNetTool.csproj │ │ ├── Options │ │ ├── CommonOptions.cs │ │ ├── GenerationOptions.cs │ │ └── InterfaceGenerationOptions.cs │ │ ├── Program.cs │ │ └── Savers │ │ ├── FileSaver.cs │ │ └── ISaver.cs └── NClient │ ├── NClient.Abstractions │ ├── Annotations │ │ ├── Auth │ │ │ ├── IAnonymousAttribute.cs │ │ │ └── IAuthorizedAttribute.cs │ │ ├── Common │ │ │ ├── INameProviderAttribute.cs │ │ │ ├── IOrderProviderAttribute.cs │ │ │ └── IPathProviderAttribute.cs │ │ ├── Http │ │ │ ├── IHeaderAttribute.cs │ │ │ ├── IHttpFacadeAttribute.cs │ │ │ ├── Methods │ │ │ │ ├── IDeleteMethodAttribute.cs │ │ │ │ ├── IGetMethodAttribute.cs │ │ │ │ ├── IHeadMethodAttribute.cs │ │ │ │ ├── IOptionsMethodAttribute.cs │ │ │ │ ├── IPatchMethodAttribute.cs │ │ │ │ ├── IPostMethodAttribute.cs │ │ │ │ └── IPutMethodAttribute.cs │ │ │ └── Parameters │ │ │ │ ├── IBodyParamAttribute.cs │ │ │ │ ├── IFormParamAttribute.cs │ │ │ │ ├── IHeaderParamAttribute.cs │ │ │ │ ├── IQueryParamAttribute.cs │ │ │ │ └── IRouteParamAttribute.cs │ │ ├── IFacadeAttribute.cs │ │ ├── IMetadataAttribute.cs │ │ ├── IOverrideAttribute.cs │ │ ├── IPathAttribute.cs │ │ ├── IResponseAttribute.cs │ │ ├── ITimeoutAttribute.cs │ │ ├── Operations │ │ │ ├── ICheckOperationAttribute.cs │ │ │ ├── ICreateOperationAttribute.cs │ │ │ ├── ICustomOperationAttribute.cs │ │ │ ├── IDeleteOperationAttribute.cs │ │ │ ├── IInfoOperationAttribute.cs │ │ │ ├── IOperationAttribute.cs │ │ │ ├── IPartialUpdateOperationAttribute.cs │ │ │ ├── IReadOperationAttribute.cs │ │ │ └── IUpdateOperationAttribute.cs │ │ ├── Parameters │ │ │ ├── IContentParamAttribute.cs │ │ │ ├── IMetadataParamAttribute.cs │ │ │ ├── IParamAttribute.cs │ │ │ ├── IPathParamAttribute.cs │ │ │ └── IPropertyParamAttribute.cs │ │ └── Versioning │ │ │ ├── IToVersionAttribute.cs │ │ │ ├── IUseVersionAttribute.cs │ │ │ └── IVersionAttribute.cs │ ├── Building │ │ ├── Configuration │ │ │ ├── Handling │ │ │ │ ├── INClientHandlingSelector.cs │ │ │ │ └── INClientTransportHandlingSetter.cs │ │ │ ├── Mapping │ │ │ │ ├── INClientResponseMappingSelector.cs │ │ │ │ ├── INClientResponseMappingSetter.cs │ │ │ │ └── INClientTransportResponseMappingSetter.cs │ │ │ ├── Resilience │ │ │ │ ├── INClientFactoryResilienceMethodSelector.cs │ │ │ │ ├── INClientFactoryResilienceSetter.cs │ │ │ │ ├── INClientResilienceMethodSelector.cs │ │ │ │ └── INClientResilienceSetter.cs │ │ │ └── Validation │ │ │ │ ├── INClientResponseValidationSelector.cs │ │ │ │ └── INClientTransportResponseValidationSetter.cs │ │ ├── Factory │ │ │ ├── INClientFactoryApiBuilder.cs │ │ │ ├── INClientFactoryOptionalBuilder.cs │ │ │ ├── INClientFactorySerializationBuilder.cs │ │ │ └── INClientFactoryTransportBuilder.cs │ │ ├── INClientApiBuilder.cs │ │ ├── INClientOptionalBuilder.cs │ │ ├── INClientSerializationBuilder.cs │ │ └── INClientTransportBuilder.cs │ ├── Clients │ │ ├── IResilienceNClient.cs │ │ └── ITransportNClient.cs │ ├── Exceptions │ │ ├── ClientArgumentException.cs │ │ ├── ClientException.cs │ │ ├── ClientValidationException.cs │ │ ├── NClientException.cs │ │ └── TransportException.cs │ ├── Extensions │ │ ├── Handling │ │ │ └── ExtraHandlingExtensions.cs │ │ ├── Logging │ │ │ └── ExtraLoggingExtensions.cs │ │ ├── Mapping │ │ │ └── ExtraMappingExtensions.cs │ │ └── Validation │ │ │ └── ExtraResponseValidationExtensions.cs │ ├── INClient.cs │ ├── INClientBuilder.cs │ ├── INClientFactory.cs │ ├── INClientFactoryBuilder.cs │ ├── Invocation │ │ ├── IMethod.cs │ │ ├── IMethodInvocation.cs │ │ ├── IMethodParam.cs │ │ ├── Method.cs │ │ ├── MethodInvocation.cs │ │ └── MethodParam.cs │ ├── Models │ │ ├── IStreamContent.cs │ │ └── StreamContent.cs │ ├── NClient.Abstractions.csproj │ └── Providers │ │ ├── Api │ │ ├── IRequestBuilder.cs │ │ └── IRequestBuilderProvider.cs │ │ ├── Authorization │ │ ├── AccessToken.cs │ │ ├── IAccessToken.cs │ │ ├── IAccessTokens.cs │ │ ├── IAuthorization.cs │ │ ├── IAuthorizationProvider.cs │ │ └── SingleAccessToken.cs │ │ ├── Handling │ │ ├── ClientHandlerSettings.cs │ │ ├── IClientHandler.cs │ │ ├── IClientHandlerProvider.cs │ │ └── IClientHandlerSettings.cs │ │ ├── Mapping │ │ ├── IResponseMapper.cs │ │ └── IResponseMapperProvider.cs │ │ ├── Resilience │ │ ├── IMethodResiliencePolicyProvider.cs │ │ ├── IResiliencePolicy.cs │ │ ├── IResiliencePolicyProvider.cs │ │ ├── IResiliencePolicySettings.cs │ │ └── ResiliencePolicySettings.cs │ │ ├── Serialization │ │ ├── ISerializer.cs │ │ └── ISerializerProvider.cs │ │ ├── Tools │ │ ├── IToolSet.cs │ │ └── ToolSet.cs │ │ ├── Transport │ │ ├── Common │ │ │ ├── Content.cs │ │ │ ├── IContent.cs │ │ │ ├── IMetadata.cs │ │ │ ├── IMetadataContainer.cs │ │ │ ├── IParameter.cs │ │ │ ├── IPipelineCanceller.cs │ │ │ ├── Metadata.cs │ │ │ ├── MetadataContainer.cs │ │ │ ├── MultipartContent.cs │ │ │ └── Parameter.cs │ │ ├── Context │ │ │ ├── IResponseContext.cs │ │ │ └── ResponseContext.cs │ │ ├── IResponseBuilder.cs │ │ ├── IResponseBuilderProvider.cs │ │ ├── ITransport.cs │ │ ├── ITransportProvider.cs │ │ ├── ITransportRequestBuilder.cs │ │ ├── ITransportRequestBuilderProvider.cs │ │ ├── Requests │ │ │ ├── IRequest.cs │ │ │ ├── Request.cs │ │ │ └── RequestType.cs │ │ └── Responses │ │ │ ├── IResponse.cs │ │ │ ├── IResponseWithError.cs │ │ │ ├── Response.cs │ │ │ └── ResponseWithError.cs │ │ └── Validation │ │ ├── IResponseValidator.cs │ │ ├── IResponseValidatorProvider.cs │ │ ├── IResponseValidatorSettings.cs │ │ └── ResponseValidatorSettings.cs │ ├── NClient.Annotations │ ├── Auth │ │ ├── AnonymousAttribute.cs │ │ └── AuthorizedAttribute.cs │ ├── FacadeAttribute.cs │ ├── Http │ │ ├── HeaderAttribute.cs │ │ ├── HttpFacadeAttribute.cs │ │ ├── Methods │ │ │ ├── DeleteMethodAttribute.cs │ │ │ ├── GetMethodAttribute.cs │ │ │ ├── HeadMethodAttribute.cs │ │ │ ├── OptionsMethodAttribute.cs │ │ │ ├── PatchMethodAttribute.cs │ │ │ ├── PostMethodAttribute.cs │ │ │ └── PutMethodAttribute.cs │ │ └── Parameters │ │ │ ├── BodyParamAttribute.cs │ │ │ ├── FormParamAttribute.cs │ │ │ ├── HeaderParamAttribute.cs │ │ │ ├── QueryParamAttribute.cs │ │ │ └── RouteParamAttribute.cs │ ├── MetadataAttribute.cs │ ├── NClient.Annotations.csproj │ ├── Operations │ │ ├── CheckOperationAttribute.cs │ │ ├── CreateOperationAttribute.cs │ │ ├── CustomOperationAttribute.cs │ │ ├── DeleteOperationAttribute.cs │ │ ├── InfoOperationAttribute.cs │ │ ├── OperationAttribute.cs │ │ ├── PartialUpdateOperationAttribute.cs │ │ ├── ReadOperationAttribute.cs │ │ └── UpdateOperationAttribute.cs │ ├── OverrideAttribute.cs │ ├── Parameters │ │ ├── ContentParamAttribute.cs │ │ ├── MetadataParamAttribute.cs │ │ ├── ParamAttribute.cs │ │ ├── PathParamAttribute.cs │ │ └── PropertyParamAttribute.cs │ ├── PathAttribute.cs │ ├── ResponseAttribute.cs │ ├── TimeoutAttribute.cs │ └── Versioning │ │ ├── ToVersionAttribute.cs │ │ ├── UseVersionAttribute.cs │ │ └── VersionAttribute.cs │ ├── NClient.AspNetCore │ ├── AspNetBinding │ │ ├── BodyModelBinder.cs │ │ ├── BodyModelBinderProvider.cs │ │ ├── ComplexTypeModelBinder.cs │ │ ├── ComplexTypeModelBinderProvider.cs │ │ ├── MvcCoreLoggerExtensions.cs │ │ └── Resources.cs │ ├── Binding │ │ └── ModelExtender.cs │ ├── Controllers │ │ ├── ControllerQualifier.cs │ │ ├── Models │ │ │ ├── NClientControllerInfo.cs │ │ │ └── VirtualControllerInfo.cs │ │ ├── NClientControllerFinder.cs │ │ ├── VirtualControllerAttributeBuilder.cs │ │ ├── VirtualControllerFeatureProvider.cs │ │ ├── VirtualControllerGenerator.cs │ │ └── VirtualControllerInterceptor.cs │ ├── Exceptions │ │ ├── ControllerArgumentException.cs │ │ ├── ControllerException.cs │ │ ├── ControllerValidationException.cs │ │ ├── Factories │ │ │ ├── ControllerObjectMemberManagerExceptionFactory.cs │ │ │ └── ControllerValidationExceptionFactory.cs │ │ └── HttpResponseException.cs │ ├── Extensions │ │ └── AddNClientControllersExtensions.cs │ ├── Filters │ │ └── HttpResponseExceptionFilter.cs │ ├── Mappers │ │ └── NClientAttributeMapper.cs │ ├── NClient.AspNetCore.csproj │ └── NClientAssemblyNames.cs │ ├── NClient.AspNetProxy.Standalone │ ├── Controllers │ │ ├── VirtualControllerFeatureProvider.cs │ │ ├── VirtualControllerGenerator.cs │ │ ├── VirtualControllerInterceptor.cs │ │ └── VirtualControllerRegistrar.cs │ ├── Exceptions │ │ └── Factories │ │ │ └── OuterAspNetExceptionFactory.cs │ ├── Extensions │ │ └── AddNClientControllersExtensions.cs │ ├── Mappers │ │ └── NClientAttributeMapper.cs │ ├── NClient.AspNetProxy.Standalone.csproj │ └── NClientAssemblyNames.cs │ ├── NClient.Common │ ├── Helpers │ │ ├── Converters.cs │ │ ├── Ensure.cs │ │ ├── EnumExtensions.cs │ │ └── StreamExtenstions.cs │ └── NClient.Common.csproj │ ├── NClient.Core │ ├── AspNetRouting │ │ ├── ArrayBuilder.cs │ │ ├── InlineConstraint.cs │ │ ├── PropertyHelper.cs │ │ ├── RegexRouteConstraint.cs │ │ ├── Resources.cs │ │ ├── RouteParameterParser.cs │ │ ├── RoutePattern.cs │ │ ├── RoutePatternException.cs │ │ ├── RoutePatternFactory.cs │ │ ├── RoutePatternLiteralPart.cs │ │ ├── RoutePatternParameterKind.cs │ │ ├── RoutePatternParameterPart.cs │ │ ├── RoutePatternParameterPolicyReference.cs │ │ ├── RoutePatternParser.cs │ │ ├── RoutePatternPart.cs │ │ ├── RoutePatternPartKind.cs │ │ ├── RoutePatternPathSegment.cs │ │ ├── RoutePatternSeparatorPart.cs │ │ ├── RoutePrecedence.cs │ │ ├── RouteTemplate.cs │ │ ├── RouteValueEqualityComparer.cs │ │ ├── TemplateParser.cs │ │ ├── TemplatePart.cs │ │ └── TemplateSegment.cs │ ├── Castle │ │ └── AsyncInterceptorBase.cs │ ├── Extensions │ │ ├── MethodCancellationTokenExtensions.cs │ │ └── RequestTypeExtensions.cs │ ├── Helpers │ │ ├── EnumerableExtensions.cs │ │ ├── EqualityComparers │ │ │ ├── MethodInfoEqualityComparer.cs │ │ │ ├── OverridingMethodInfoEqualityComparer.cs │ │ │ └── ReferenceAttributeEqualityComparer.cs │ │ ├── GuidProvider.cs │ │ ├── ObjectMemberManagers │ │ │ ├── Factories │ │ │ │ └── IObjectMemberManagerExceptionFactory.cs │ │ │ ├── MemberNameSelectors │ │ │ │ ├── BodyMemberNameSelector.cs │ │ │ │ ├── DefaultMemberNameSelector.cs │ │ │ │ ├── IMemberNameSelector.cs │ │ │ │ └── QueryMemberNameSelector.cs │ │ │ └── ObjectMemberManager.cs │ │ ├── ObjectToKeyValueConverters │ │ │ ├── Factories │ │ │ │ └── IObjectToKeyValueConverterExceptionFactory.cs │ │ │ ├── ObjectToKeyValueConverter.cs │ │ │ └── PropertyKeyValue.cs │ │ ├── PathHelper.cs │ │ └── TypeExtensions.cs │ ├── Mappers │ │ └── AttributeMapper.cs │ ├── NClient.Core.csproj │ └── Proxy │ │ ├── IProxyGeneratorProvider.cs │ │ └── SingletonProxyGeneratorProvider.cs │ ├── NClient.InterfaceProxy.Standalone │ ├── Mappers │ │ └── AspNetAttributeMapper.cs │ ├── NClient.InterfaceProxy.Standalone.csproj │ ├── NClientBuilder.cs │ ├── NClientControllerBuilder.cs │ ├── NClientControllerFactory.cs │ ├── NClientControllerStandaloneProvider.cs │ ├── NClientFactory.cs │ ├── NClientStandaloneProvider.cs │ └── Validators │ │ ├── ClientControllerValidator.cs │ │ └── ClientInterfaceValidator.cs │ ├── NClient.InterfaceProxy │ ├── Extensions │ │ ├── NClientBuilderExtensions.cs │ │ └── NClientControllerBuilderExtensions.cs │ ├── NClient.InterfaceProxy.csproj │ ├── NClientControllerProvider.cs │ └── NClientProvider.cs │ ├── NClient.Standalone │ ├── Client │ │ ├── Authorization │ │ │ ├── Authorization.cs │ │ │ ├── AuthorizationProvider.cs │ │ │ ├── CompositeAuthorization.cs │ │ │ └── CompositeAuthorizationProvider.cs │ │ ├── Handling │ │ │ ├── ClientHandler.cs │ │ │ ├── ClientHandlerProvider.cs │ │ │ ├── CompositeClientHandler.cs │ │ │ └── CompositeClientHandlerProvider.cs │ │ ├── Logging │ │ │ ├── CompositeDisposable.cs │ │ │ └── CompositeLogger.cs │ │ ├── Mapping │ │ │ ├── CompositeResponseMapper.cs │ │ │ ├── CompositeResponseMapperProvider.cs │ │ │ └── ResponseMapperProvider.cs │ │ ├── Resilience │ │ │ ├── MethodResiliencePolicyProviderAdapter.cs │ │ │ └── ResiliencePolicyProvider.cs │ │ ├── TransportNClient.cs │ │ ├── TransportNClientFactory.cs │ │ └── Validation │ │ │ ├── CompositeResponseValidator.cs │ │ │ └── CompositeResponseValidatorProvider.cs │ ├── ClientProxy │ │ ├── Building │ │ │ ├── Configuration │ │ │ │ ├── Handling │ │ │ │ │ ├── NClientHandlingSelector.cs │ │ │ │ │ └── NClientTransportHandlingSetter.cs │ │ │ │ ├── Mapping │ │ │ │ │ ├── NClientResponseMappingSelector.cs │ │ │ │ │ ├── NClientResponseMappingSetter.cs │ │ │ │ │ └── NClientTransportResponseMappingSetter.cs │ │ │ │ ├── Resilience │ │ │ │ │ ├── NClientFactoryResilienceMethodSelector.cs │ │ │ │ │ ├── NClientFactoryResilienceSetter.cs │ │ │ │ │ ├── NClientResilienceMethodSelector.cs │ │ │ │ │ └── NClientResilienceSetter.cs │ │ │ │ └── Validation │ │ │ │ │ ├── NClientResponseValidationSelector.cs │ │ │ │ │ └── NClientTransportResponseValidationSetter.cs │ │ │ ├── Context │ │ │ │ ├── BuilderContext.cs │ │ │ │ └── BuilderContextModifier.cs │ │ │ ├── Factory │ │ │ │ ├── NClientFactoryApiBuilder.cs │ │ │ │ ├── NClientFactoryOptionalBuilder.cs │ │ │ │ ├── NClientFactorySerializationBuilder.cs │ │ │ │ └── NClientFactoryTransportBuilder.cs │ │ │ ├── Models │ │ │ │ └── ResiliencePolicyPredicate.cs │ │ │ ├── NClientApiBuilder.cs │ │ │ ├── NClientOptionalBuilder.cs │ │ │ ├── NClientSerializationBuilder.cs │ │ │ └── NClientTransportBuilder.cs │ │ ├── Generation │ │ │ ├── ClientGenerator.cs │ │ │ ├── Helpers │ │ │ │ └── TimeoutSelector.cs │ │ │ ├── Interceptors │ │ │ │ ├── ClientInterceptor.cs │ │ │ │ ├── ClientInterceptorFactory.cs │ │ │ │ └── KeepDataInterceptor.cs │ │ │ ├── Invocation │ │ │ │ ├── ClientInvocationProvider.cs │ │ │ │ ├── ClientMethodInvocation.cs │ │ │ │ ├── ExplicitMethodInvocation.cs │ │ │ │ └── ExplicitMethodInvocationProvider.cs │ │ │ └── MethodBuilders │ │ │ │ ├── MethodBuilder.cs │ │ │ │ ├── MethodParamBuilder.cs │ │ │ │ └── Providers │ │ │ │ ├── MetadataAttributeProvider.cs │ │ │ │ ├── OperationAttributeProvider.cs │ │ │ │ ├── ParamAttributeProvider.cs │ │ │ │ ├── PathAttributeProvider.cs │ │ │ │ ├── TimeoutAttributeProvider.cs │ │ │ │ └── UseVersionAttributeProvider.cs │ │ └── Validation │ │ │ ├── Api │ │ │ ├── StubRequestBuilder.cs │ │ │ └── StubRequestBuilderProvider.cs │ │ │ ├── Authorization │ │ │ ├── StubAuthorization.cs │ │ │ └── StubAuthorizationProvider.cs │ │ │ ├── ClientValidator.cs │ │ │ ├── Handling │ │ │ ├── StubClientHandler.cs │ │ │ └── StubClientHandlerProvider.cs │ │ │ ├── PipelineCanceller.cs │ │ │ ├── Resilience │ │ │ ├── StubResiliencePolicy.cs │ │ │ └── StubResiliencePolicyProvider.cs │ │ │ ├── Serialization │ │ │ ├── StubSerializer.cs │ │ │ └── StubSerializerProvider.cs │ │ │ ├── Transport │ │ │ ├── StubResponseBuilder.cs │ │ │ ├── StubResponseBuilderProvider.cs │ │ │ ├── StubTransportBuilder.cs │ │ │ ├── StubTransportProvider.cs │ │ │ ├── StubTransportRequestBuilder.cs │ │ │ └── StubTransportRequestBuilderProvider.cs │ │ │ └── Validation │ │ │ ├── StubResponseValidator.cs │ │ │ └── StubResponseValidatorProvider.cs │ ├── Exceptions │ │ ├── ClientBuildException.cs │ │ ├── ClientRequestException.cs │ │ └── Factories │ │ │ ├── ClientBuildExceptionFactory.cs │ │ │ ├── ClientRequestExceptionFactory.cs │ │ │ └── ClientValidationExceptionFactory.cs │ ├── Extensions │ │ ├── Authorization │ │ │ └── AuthorizationExtensions.cs │ │ ├── Handling │ │ │ ├── HandlingExtensions.cs │ │ │ └── TransportHandlingExtensions.cs │ │ ├── Mapping │ │ │ └── Results │ │ │ │ ├── ResultsExtensions.cs │ │ │ │ └── UseResultsExtensions.cs │ │ ├── NClientExtensions.cs │ │ ├── Resilience │ │ │ ├── FullResilienceExtensions.cs │ │ │ ├── IdempotentResilienceExtensions.cs │ │ │ └── SafeResilienceExtensions.cs │ │ └── Validation │ │ │ ├── ResponseValidationExtensions.cs │ │ │ └── UseTransportResponseExtensions.cs │ ├── NClient.Standalone.csproj │ ├── NClientBuilder.cs │ ├── NClientFactory.cs │ ├── NClientFactoryBuilder.cs │ ├── Options │ │ ├── NClientBuilderOptions.cs │ │ └── NClientFactoryBuilderOptions.cs │ └── Providers │ │ ├── Mapping │ │ ├── ResponseToResult │ │ │ ├── ResponseToResultMapper.cs │ │ │ ├── ResponseToResultMapperProvider.cs │ │ │ └── Result.cs │ │ └── ResponseToStream │ │ │ ├── ResponseToStreamMapper.cs │ │ │ └── ResponseToStreamMapperProvider.cs │ │ └── Validation │ │ ├── ResponseValidator.cs │ │ └── ResponseValidatorProvider.cs │ └── NClient │ ├── Extensions │ ├── HttpTransportExtensions.cs │ ├── JsonSerializerExtensions.cs │ ├── Resilience │ │ ├── FullResilienceExtensions.cs │ │ ├── IdempotentResilienceExtensions.cs │ │ ├── SafeResilienceExtensions.cs │ │ └── UseResilienceExtensions.cs │ ├── Streams │ │ ├── StreamsExtensions.cs │ │ └── UseStreamsExtensions.cs │ └── Validation │ │ ├── ResponseValidationExtensions.cs │ │ └── UseResponseValidationExtensions.cs │ ├── Gallery │ ├── ClientFactoryGallery.cs │ ├── ClientGallery.cs │ └── NClientGallery.cs │ ├── NClient.csproj │ ├── RestNClientBuilder.cs │ └── RestNClientFactoryBuilder.cs └── tests ├── NClient.Api └── NClient.Api.Tests │ ├── BasicClientUseCases │ ├── HandlingTest.cs │ ├── LoggingTest.cs │ ├── ResilienceTest.cs │ ├── ResponseValidationTest.cs │ └── SerializerTest.cs │ ├── CustomClientUseCases │ ├── HttpClientTest.cs │ └── ResponseValidationTest.cs │ ├── NClient.Api.Tests.csproj │ └── Stubs │ ├── CustomHandler.cs │ ├── CustomLogger.cs │ └── CustomResponseValidatorSettings.cs ├── NClient.CodeGeneration └── NClient.CodeGeneration.Interfaces.NSwag.Tests │ ├── NClient.CodeGeneration.Interfaces.NSwag.Tests.csproj │ ├── NSwagGeneratorTest.cs │ └── Specifications │ ├── swagger.json │ ├── swagger.yaml │ └── uber.json ├── NClient.Extensions └── NClient.Extensions.DependencyInjection.Tests │ ├── AddCustomNClientExtensionsTest.cs │ ├── AddCustomNClientFactoryExtensionsTest.cs │ ├── AddRestNClientExtensionsTest.cs │ ├── AddRestNClientFactoryExtensionsTest.cs │ ├── Helpers │ ├── ConstIntJsonConverter.cs │ ├── LoggerFactoryMockFactory.cs │ └── LoggerMockFactory.cs │ └── NClient.Extensions.DependencyInjection.Tests.csproj ├── NClient.Packages └── NClient.Packages.Tests │ ├── ClientTest.cs │ ├── Helpers │ └── PackagesVersionProvider.cs │ ├── NClient.Packages.Tests.csproj │ ├── ToolTest.cs │ └── VersionTest.cs ├── NClient.Providers ├── NClient.Providers.Api.Rest.Tests │ ├── Helpers │ │ └── FormUrlEncoderTest.cs │ ├── HttpMethodProviderTests │ │ └── RequestTypeProviderTest.cs │ ├── NClient.Providers.Api.Rest.Tests.csproj │ ├── RequestBuilderTestBase.cs │ ├── RequestBuilderTests │ │ ├── RequestBuilderBodyTest.cs │ │ ├── RequestBuilderHeaderTest.cs │ │ ├── RequestBuilderMethodTest.cs │ │ ├── RequestBuilderQueryTest.cs │ │ └── RequestBuilderRouteTest.cs │ └── RouteProviderTests │ │ └── RouteProviderTest.cs ├── NClient.Providers.Mapping.HttpResponses.Tests │ ├── HttpResponseBuilderTest.cs │ ├── HttpResponseDeconstructTest.cs │ └── NClient.Providers.Mapping.HttpResponses.Tests.csproj ├── NClient.Providers.Mapping.LanguageExt.Tests │ ├── EitherBuilderTest.cs │ └── NClient.Providers.Mapping.LanguageExt.Tests.csproj ├── NClient.Providers.Serialization.MessagePack.Tests │ ├── MessagePackSerializerTest.cs │ ├── Models │ │ ├── Dot.cs │ │ ├── NotMP.cs │ │ └── Point.cs │ └── NClient.Providers.Serialization.MessagePack.Tests.csproj ├── NClient.Providers.Serialization.ProtobufNet.Tests │ ├── Models │ │ ├── NotProto.cs │ │ └── Point.cs │ ├── NClient.Providers.Serialization.ProtobufNet.Tests.csproj │ └── ProtobufNetSerializerTest.cs ├── NClient.Providers.Serialization.SystemTextJson.Tests │ ├── Contexts │ │ └── BasicEntityJsonContext.cs │ ├── NClient.Providers.Serialization.SystemTextJson.Tests.csproj │ └── SystemTextJsonClientTest.cs ├── NClient.Providers.Serialization.SystemXml.Tests │ ├── NClient.Providers.Serialization.SystemXml.Tests.csproj │ └── SystemXmlSerializerTest.cs └── NClient.Providers.Transport.SystemNetHttp.Tests │ ├── NClient.Providers.Transport.SystemNetHttp.Tests.csproj │ ├── ResponseDeconstructTest.cs │ └── SystemNetHttpClientTest.cs ├── NClient.Testing └── NClient.Testing.Common │ ├── Apis │ ├── AuthorizationApiMockFactory.cs │ ├── BasicApiMockFactory.cs │ ├── CancellationApiMockFactory.cs │ ├── FileApiMockFactory.cs │ ├── FormUrlencodedApiMockFactory.cs │ ├── GenericApiMockFactory.cs │ ├── HeaderApiMockFactory.cs │ ├── HttpResponseApiMockFactory.cs │ ├── MultipartApiMockFactory.cs │ ├── OptionalParamApiMockFactory.cs │ ├── OverriddenApiMockFactory.cs │ ├── QueryApiMockFactory.cs │ ├── ResponseApiMockFactory.cs │ ├── ResponseStreamApiMockFactory.cs │ ├── RestApiMockFactory.cs │ ├── ResultApiMockFactory.cs │ ├── ReturnApiMockFactory.cs │ ├── SyncApiMockFactory.cs │ └── TimeoutApiMockFactory.cs │ ├── Clients │ ├── ClassClient.cs │ ├── ClassClientWithMetadata.cs │ ├── IAuthorizationClient.cs │ ├── IAuthorizationClientWithMetadata.cs │ ├── IBasicClient.cs │ ├── IBasicClientWithMetadata.cs │ ├── ICancellationClient.cs │ ├── ICancellationClientWithMetadata.cs │ ├── IFileClient.cs │ ├── IFileClientWithMetadata.cs │ ├── IFormUrlencodedClient.cs │ ├── IFormUrlencodedClientWithMetadata.cs │ ├── IGenericClientWithMetadata.cs │ ├── IHeaderClient.cs │ ├── IHeaderClientWithMetadata.cs │ ├── IHttpResponseClient.cs │ ├── IHttpResponseClientWithMetadata.cs │ ├── IMultipartClient.cs │ ├── IMultipartClientWithMetadata.cs │ ├── IOptionalParamClient.cs │ ├── IOptionalParamClientWithMetadata.cs │ ├── IOverriddenClientWithMetadata.cs │ ├── IQueryClient.cs │ ├── IQueryClientWithMetadata.cs │ ├── IResponseClient.cs │ ├── IResponseClientWithMetadata.cs │ ├── IResponseStreamClient.cs │ ├── IRestClient.cs │ ├── IRestClientWithMetadata.cs │ ├── IResultClient.cs │ ├── IResultClientWithMetadata.cs │ ├── IReturnClient.cs │ ├── IReturnClientWithMetadata.cs │ ├── ISyncClient.cs │ ├── ISyncClientWithMetadata.cs │ ├── ITimeoutClient.cs │ ├── ITimeoutClientWithMetadata.cs │ └── ITimeoutStaticClientWithMetadata.cs │ ├── Entities │ ├── BasicEntity.cs │ ├── BasicEntityWithCustomFromQueryName.cs │ ├── BasicEntityWithCustomJsonName.cs │ ├── BasicEntityWithCustomQueryName.cs │ ├── EntityWithArray.cs │ ├── EntityWithCustomTypeArray.cs │ ├── EntityWithCustomTypeDict.cs │ ├── EntityWithDict.cs │ ├── Error.cs │ ├── HttpError.cs │ └── NestedEntity.cs │ ├── Helpers │ ├── DelayClientHandler.cs │ ├── HttpKnownHeaderNames.cs │ └── UriExtensions.cs │ └── NClient.Testing.Common.csproj ├── NClient.Tools └── NClient.DotNetTool.Tests │ └── NClient.DotNetTool.Tests.csproj └── NClient ├── NClient.AspNetCore.Tests ├── ControllerQualifierTest.cs ├── NClient.AspNetCore.Tests.csproj └── VirtualControllerGeneratorTests │ └── VirtualControllerGeneratorTest.cs ├── NClient.Core.Tests ├── NClient.Core.Tests.csproj └── ObjectMemberManagerTest.cs ├── NClient.InterfaceProxy.Tests └── NClient.InterfaceProxy.Tests.csproj ├── NClient.Standalone.Tests ├── Clients │ └── IResponseStreamClient.cs ├── MethodBuilders │ ├── MethodBuilderTest.cs │ ├── MethodParamBuilderTest.cs │ └── Providers │ │ ├── HeaderAttributeProviderTest.cs │ │ ├── MethodAttributeProviderTest.cs │ │ ├── ParamAttributeProviderTest.cs │ │ ├── PathAttributeProviderTest.cs │ │ └── UseVersionAttributeProviderTest.cs ├── NClient.Standalone.Tests.csproj ├── ObjectToKeyValueTest.cs ├── ResponseValidationTest.cs ├── ResultDeconstructTest.cs ├── TimeoutSelectorTest.cs └── Validation │ └── ClientValidatorTest.cs └── NClient.Tests ├── ClientFactoryTests ├── Helpers │ └── ClientTestBase.cs └── ResilienceNClientFactoryTest.cs ├── ClientTests ├── AuthorizationClientTest.cs ├── BasicClientTest.cs ├── CancellationClientTest.cs ├── ClassClientTest.cs ├── FileClientTest.cs ├── FormUrlencodedClientTest.cs ├── GenericClientTest.cs ├── HeaderClientTest.cs ├── Helpers │ └── ClientTestBase.cs ├── HttpNClientTest.cs ├── HttpResponseClientTest.cs ├── MultipartClientTest.cs ├── OptionalParamClientTest.cs ├── OverrideClientTest.cs ├── QueryClientTest.cs ├── ResilienceNClientTest.cs ├── ResponseClientTest.cs ├── ResponseStreamClientTest.cs ├── RestClientTest.cs ├── ResultClientTest.cs ├── ReturnClientTest.cs ├── SyncClientTest.cs ├── TimeoutClientTest.cs └── TimeoutStaticClientTest.cs └── NClient.Tests.csproj /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: 'Type: Bug' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Do this '...' 16 | 2. Do that '....' 17 | 18 | **Expected behavior** 19 | A clear and concise description of what you expected to happen. 20 | 21 | **Project info (please complete the following information):** 22 | - Version NClient [e.g. 0.1.0] 23 | - Version .Net [e.g. .Net 5.0.103] 24 | 25 | **Additional context** 26 | Add any other context about the problem here. 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: 'Type: Enhancement' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. 4 | -------------------------------------------------------------------------------- /.github/workflows/notifications.yml: -------------------------------------------------------------------------------- 1 | name: 'Notifications' 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | types: [ opened, closed, reopened, ready_for_review, review_requested ] 7 | issues: 8 | types: [ opened, edited, deleted, closed, reopened ] 9 | fork: 10 | watch: 11 | 12 | jobs: 13 | notification: 14 | name: Notification 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: telegram-notify 18 | uses: appleboy/telegram-action@master 19 | with: 20 | to: ${{ secrets.TELEGRAM_CHAT_ID }} 21 | token: ${{ secrets.TELEGRAM_BOT_API }} 22 | message: | 23 | Hello there, 24 | There is new ${{ github.event_name }} in NClient by ${{ github.actor }}. 25 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/Clients/Flurl/FlurlHttpClientFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using Flurl.Http.Configuration; 3 | using RichardSzalay.MockHttp; 4 | 5 | namespace NClient.Benchmark.Client.Clients.Flurl 6 | { 7 | public class FlurlHttpClientFactory : DefaultHttpClientFactory 8 | { 9 | private readonly MockHttpMessageHandler _mockHttpMessageHandler; 10 | 11 | public FlurlHttpClientFactory(MockHttpMessageHandler mockHttpMessageHandler) 12 | { 13 | _mockHttpMessageHandler = mockHttpMessageHandler; 14 | } 15 | 16 | public override HttpMessageHandler CreateMessageHandler() 17 | { 18 | return _mockHttpMessageHandler; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/Dtos/Dto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NClient.Benchmark.Client.Dtos 5 | { 6 | public class Dto 7 | { 8 | public long Id { get; set; } 9 | public int Int { get; set; } 10 | public double Double { get; set; } 11 | public decimal Decimal { get; set; } 12 | public string? String { get; set; } 13 | public DateTime DateTime { get; set; } 14 | public TimeSpan TimeSpan { get; set; } 15 | public Uri? Uri { get; set; } 16 | public Guid Guid { get; set; } 17 | public Dto? InnerDto { get; set; } 18 | public List? List { get; set; } 19 | public Dictionary? Dictionary { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/Dtos/DtoJsonContext.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace NClient.Benchmark.Client.Dtos 4 | { 5 | [JsonSerializable(typeof(Dto))] 6 | public partial class DtoJsonContext : JsonSerializerContext 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/Helpers/IdProvider.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Benchmark.Client.Helpers 2 | { 3 | public class IdProvider 4 | { 5 | private static int _id; 6 | 7 | public static int Get() => _id++; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/HttpMock/MockDtoHttpMessageHandlerBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json; 3 | using RichardSzalay.MockHttp; 4 | 5 | namespace NClient.Benchmark.Client.HttpMock 6 | { 7 | public static class MockDtoHttpMessageHandlerBuilder 8 | { 9 | public static Uri Uri { get; } = new("http://localhost:5000/api"); 10 | public static string Host { get; } = Uri.GetLeftPart(UriPartial.Authority); 11 | public static string Path { get; } = Uri.PathAndQuery; 12 | 13 | public static MockHttpMessageHandler Build(T response) 14 | { 15 | var mock = new MockHttpMessageHandler(); 16 | mock 17 | .When(Uri.ToString()) 18 | .Respond(mediaType: "application/json", content: JsonSerializer.Serialize(response)); 19 | return mock; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/HttpMock/MockIdHttpMessageHandlerBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json; 3 | using RichardSzalay.MockHttp; 4 | 5 | namespace NClient.Benchmark.Client.HttpMock 6 | { 7 | public static class MockIdHttpMessageHandlerBuilder 8 | { 9 | public static Uri Uri { get; } = new("http://localhost:5000/api"); 10 | public static string Host { get; } = Uri.GetLeftPart(UriPartial.Authority); 11 | public static string Path { get; } = Uri.GetLeftPart(UriPartial.Path); 12 | 13 | public static MockHttpMessageHandler Build(string paramName, T response) where T : struct 14 | { 15 | var mock = new MockHttpMessageHandler(); 16 | mock 17 | .When("*") 18 | .Respond(mediaType: "application/json", content: JsonSerializer.Serialize(response)); 19 | return mock; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/JsonClient/JsonClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations.Http; 3 | using NClient.Benchmark.Client.Dtos; 4 | 5 | namespace NClient.Benchmark.Client.JsonClient 6 | { 7 | public interface IJsonClient 8 | { 9 | [PostMethod("/api")] 10 | [Refit.Post("/api")] 11 | [RestEase.Post("/api")] 12 | Task SendAsync([BodyParam, Refit.Body, RestEase.Body] Dto dto); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/JsonHttpResponseClient/JsonHttpResponseClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations.Http; 3 | using NClient.Benchmark.Client.Dtos; 4 | using NClient.Providers.Results.HttpResults; 5 | 6 | namespace NClient.Benchmark.Client.JsonHttpResponseClient 7 | { 8 | public interface INClientJsonHttpResponseClient 9 | { 10 | [PostMethod("/api")] 11 | Task> SendAsync([BodyParam] Dto dto); 12 | } 13 | 14 | public interface IRefitJsonHttpResponseClient 15 | { 16 | [Refit.Post("/api")] 17 | Task> SendAsync([Refit.Body] Dto dto); 18 | } 19 | 20 | public interface IRestEaseJsonHttpResponseClient 21 | { 22 | [RestEase.Post("/api")] 23 | Task> SendAsync([RestEase.Body] Dto dto); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/PrimitiveClient/PrimitiveClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations.Http; 3 | 4 | namespace NClient.Benchmark.Client.PrimitiveClient 5 | { 6 | public interface IPrimitiveClient 7 | { 8 | [GetMethod("/api")] 9 | [Refit.Get("/api")] 10 | [RestEase.Get("/api")] 11 | Task SendAsync([QueryParam, Refit.Query, RestEase.Query] int id); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /benchmark/NClient.Benchmark.Client/PrimitiveHttpResponseClient/PrimitiveHttpResponseClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations.Http; 3 | using NClient.Providers.Results.HttpResults; 4 | 5 | namespace NClient.Benchmark.Client.PrimitiveHttpResponseClient 6 | { 7 | public interface INClientPrimitiveHttpResponseClient 8 | { 9 | [GetMethod("/api")] 10 | Task> SendAsync([QueryParam] int id); 11 | } 12 | 13 | public interface IRefitPrimitiveHttpResponseClient 14 | { 15 | [Refit.Get("/api")] 16 | Task> SendAsync([Refit.Query] int id); 17 | } 18 | 19 | public interface IRestEasePrimitiveHttpResponseClient 20 | { 21 | [RestEase.Get("/api")] 22 | Task> SendAsync([RestEase.Query] int id); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jetbrains.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nclient/NClient/2ae68a7694c5f526b89497754b998646ae470790/jetbrains.png -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nclient/NClient/2ae68a7694c5f526b89497754b998646ae470790/logo.png -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.FileService.Facade/IFileClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | using NClient.Providers.Transport; 5 | 6 | namespace NClient.Sandbox.FileService.Facade 7 | { 8 | [UseVersion("3.0")] 9 | [Header("client", "NClient")] 10 | public interface IFileClient : IFileController 11 | { 12 | [Override] 13 | new Task GetTextFileAsync([RouteParam] long id); 14 | 15 | [Override] 16 | new Task GetImageAsync(long id); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.FileService/Files/Image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nclient/NClient/2ae68a7694c5f526b89497754b998646ae470790/sandbox/NClient.Sandbox.FileService/Files/Image.jpg -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.FileService/Files/TextFile.txt: -------------------------------------------------------------------------------- 1 | Text file content -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.FileService/NClient.Sandbox.FileService.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.FileService/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace NClient.Sandbox.FileService 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) 14 | { 15 | return Host.CreateDefaultBuilder(args) 16 | .ConfigureWebHostDefaults(webBuilder => 17 | { 18 | webBuilder.UseStartup(); 19 | }); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.FileService/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "NClient.Sandbox.ProxyService": { 5 | "commandName": "Project", 6 | "launchBrowser": true, 7 | "launchUrl": "swagger", 8 | "applicationUrl": "http://localhost:5002", 9 | "environmentVariables": { 10 | "ASPNETCORE_ENVIRONMENT": "Development" 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.FileService/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.FileService/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ProxyService.Facade/Dto/WeatherForecastDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json.Serialization; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace NClient.Sandbox.ProxyService.Facade.Dto 6 | { 7 | public class WeatherForecastDto 8 | { 9 | [FromQuery(Name = "id")] 10 | [JsonPropertyName("id")] 11 | public int Id { get; set; } 12 | public DateTime Date { get; set; } 13 | public int TemperatureC { get; set; } 14 | public int TemperatureF => 32 + (int) (TemperatureC / 0.5556); 15 | public string? Summary { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ProxyService.Facade/Dto/WeatherForecastFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json.Serialization; 3 | using NClient.Annotations.Http; 4 | 5 | namespace NClient.Sandbox.ProxyService.Facade.Dto 6 | { 7 | public class WeatherForecastFilter 8 | { 9 | [QueryParam(Name = "id")] 10 | [JsonPropertyName("id")] 11 | public int? Id { get; set; } 12 | public DateTime? Date { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ProxyService.Facade/IWeatherForecastClient.cs: -------------------------------------------------------------------------------- 1 | using NClient.Annotations; 2 | using NClient.Annotations.Http; 3 | 4 | namespace NClient.Sandbox.ProxyService.Facade 5 | { 6 | [UseVersion("3.0")] 7 | [Header("client", "NClient")] 8 | public interface IWeatherForecastClient : IWeatherForecastController 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ProxyService/Clients/IThirdPartyWeatherForecastClient.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | using NClient.Sandbox.ProxyService.Facade.Dto; 5 | 6 | namespace NClient.Sandbox.ProxyService.Clients 7 | { 8 | [Path("WeatherForecast")] 9 | public interface IThirdPartyWeatherForecastClient 10 | { 11 | [GetMethod] 12 | IEnumerable Get(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ProxyService/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace NClient.Sandbox.ProxyService 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) 14 | { 15 | return Host.CreateDefaultBuilder(args) 16 | .ConfigureWebHostDefaults(webBuilder => 17 | { 18 | webBuilder.UseStartup(); 19 | }); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ProxyService/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "NClient.Sandbox.ProxyService": { 5 | "commandName": "Project", 6 | "launchBrowser": true, 7 | "launchUrl": "swagger", 8 | "applicationUrl": "http://localhost:5000", 9 | "environmentVariables": { 10 | "ASPNETCORE_ENVIRONMENT": "Development" 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ProxyService/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ProxyService/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ThirdPartyService/Models/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Sandbox.ThirdPartyService.Models 4 | { 5 | public class WeatherForecast 6 | { 7 | public int Id { get; set; } 8 | 9 | public DateTime Date { get; set; } 10 | 11 | public int TemperatureC { get; set; } 12 | 13 | public int TemperatureF => 32 + (int) (TemperatureC / 0.5556); 14 | 15 | public string? Summary { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ThirdPartyService/NClient.Sandbox.ThirdPartyService.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | 9.0 6 | enable 7 | true 8 | true 9 | false 10 | Debug;Release 11 | AnyCPU 12 | $(SolutionDir)/bin/sandbox/$(Configuration)/$(AssemblyName) 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ThirdPartyService/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace NClient.Sandbox.ThirdPartyService 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) 14 | { 15 | return Host.CreateDefaultBuilder(args) 16 | .ConfigureWebHostDefaults(webBuilder => 17 | { 18 | webBuilder.UseStartup(); 19 | }); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ThirdPartyService/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "NClient.Sandbox.ThirdPartyService": { 5 | "commandName": "Project", 6 | "launchBrowser": true, 7 | "launchUrl": "swagger", 8 | "applicationUrl": "http://localhost:5001", 9 | "environmentVariables": { 10 | "ASPNETCORE_ENVIRONMENT": "Development" 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ThirdPartyService/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sandbox/NClient.Sandbox.ThirdPartyService/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient.CodeGeneration/NClient.CodeGeneration.Abstractions/Enums/SerializeType.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.CodeGeneration.Abstractions.Enums 2 | { 3 | public enum SerializeType 4 | { 5 | SystemJsonText, 6 | NewtonsoftJson 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/NClient.CodeGeneration/NClient.CodeGeneration.Abstractions/INClientFacadeGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace NClient.CodeGeneration.Abstractions 5 | { 6 | public interface INClientFacadeGenerator 7 | { 8 | Task GenerateAsync(string specification, FacadeGenerationSettings generationSettings, CancellationToken cancellationToken = default); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient.CodeGeneration/NClient.CodeGeneration.Abstractions/INClientFacadeGeneratorProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace NClient.CodeGeneration.Abstractions 4 | { 5 | /// 6 | /// A provider abstraction for a component that can create instances. 7 | /// 8 | public interface INClientFacadeGeneratorProvider 9 | { 10 | /// 11 | /// Creates and configures an instance of instance. 12 | /// 13 | INClientFacadeGenerator Create(ILogger? logger); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient.CodeGeneration/NClient.CodeGeneration.Facades.NSwag/CSharpFacadeGeneratorSettings.cs: -------------------------------------------------------------------------------- 1 | using NSwag.CodeGeneration.CSharp; 2 | 3 | namespace NClient.CodeGeneration.Facades.NSwag 4 | { 5 | public class CSharpFacadeGeneratorSettings : CSharpControllerGeneratorSettings 6 | { 7 | public bool GenerateClients { get; set; } 8 | public bool GenerateFacades { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient.CodeGeneration/NClient.CodeGeneration.Facades.NSwag/NSwagFacadeGeneratorProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using NClient.CodeGeneration.Abstractions; 3 | 4 | namespace NClient.CodeGeneration.Facades.NSwag 5 | { 6 | public class NSwagFacadeGeneratorProvider : INClientFacadeGeneratorProvider 7 | { 8 | public INClientFacadeGenerator Create(ILogger? logger) 9 | { 10 | return new NSwagFacadeGenerator(logger); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient.CodeGeneration/NClient.CodeGeneration.Facades.NSwag/Templates/Facade.Annotations.liquid: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/NClient.CodeGeneration/NClient.CodeGeneration.Facades.NSwag/Templates/Facade.Method.Annotations.liquid: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Api.Rest/Exceptions/Factories/ClientArgumentExceptionFactory.cs: -------------------------------------------------------------------------------- 1 | using NClient.Exceptions; 2 | 3 | namespace NClient.Providers.Api.Rest.Exceptions.Factories 4 | { 5 | internal interface IClientArgumentExceptionFactory 6 | { 7 | ClientArgumentException ParameterInRouteTemplateIsNull(string parameterName); 8 | } 9 | 10 | internal class ClientArgumentExceptionFactory : IClientArgumentExceptionFactory 11 | { 12 | public ClientArgumentException ParameterInRouteTemplateIsNull(string parameterName) => 13 | new($"The parameter '{parameterName}' used in the path cannot be null."); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Api.Rest/Exceptions/Factories/ObjectToKeyValueConverterExceptionFactory.cs: -------------------------------------------------------------------------------- 1 | using NClient.Core.Helpers.ObjectToKeyValueConverters.Factories; 2 | using NClient.Exceptions; 3 | 4 | namespace NClient.Providers.Api.Rest.Exceptions.Factories 5 | { 6 | internal class ObjectToKeyValueConverterExceptionFactory : IObjectToKeyValueConverterExceptionFactory 7 | { 8 | public ClientValidationException DictionaryWithComplexTypeOfKeyNotSupported() => 9 | new("Dictionary with custom type keys cannot be passed through uri query."); 10 | 11 | public ClientValidationException DictionaryWithComplexTypeOfValueNotSupported() => 12 | new("Dictionary with custom type values cannot be passed through uri query."); 13 | 14 | public ClientValidationException ArrayWithComplexTypeNotSupported() => 15 | new("Array with custom types cannot be passed through uri query."); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Api.Rest/Models/MethodParameter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.Annotations; 3 | 4 | namespace NClient.Providers.Api.Rest.Models 5 | { 6 | internal class MethodParameter 7 | { 8 | public string Name { get; } 9 | public Type Type { get; } 10 | public object? Value { get; } 11 | public IParamAttribute Attribute { get; } 12 | 13 | public MethodParameter(string name, Type type, object? value, IParamAttribute attribute) 14 | { 15 | Name = name; 16 | Type = type; 17 | Value = value; 18 | Attribute = attribute; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Mapping.HttpResponses/Extensions/UseHttpResponsesExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using NClient.Providers.Mapping.HttpResponses; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient 6 | { 7 | public static class UseHttpResponsesExtensions 8 | { 9 | /// Sets the mapper that can convert System.Net.Http transport messages into HTTP NClient responses with deserialized data. 10 | public static INClientResponseMappingSelector UseHttpResponses( 11 | this INClientTransportResponseMappingSetter optionalBuilder) 12 | { 13 | return optionalBuilder.Use(new ResponseToHttpResponseMapperProvider()); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Mapping.HttpResponses/ResponseToHttpResponseMapperProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | 3 | namespace NClient.Providers.Mapping.HttpResponses 4 | { 5 | /// The provider of the mapper that converts System.Net.Http transport messages into HTTP NClient responses with deserialized data. 6 | public class ResponseToHttpResponseMapperProvider : IResponseMapperProvider 7 | { 8 | /// Creates the mapper that converts System.Net.Http transport messages into HTTP NClient responses with deserialized data. 9 | /// Tools that help implement providers. 10 | public IResponseMapper Create(IToolset toolset) 11 | { 12 | return new ResponseToHttpResponseMapper(toolset); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Mapping.LanguageExt/Extensions/UseLanguageExtExtensions.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Mapping.LanguageExt; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient 5 | { 6 | public static class UseLanguageExtExtensions 7 | { 8 | /// Sets the mapper that can convert NClient responses into Either monad from LanguageExt. 9 | public static INClientResponseMappingSelector UseLanguageExtMonads( 10 | this INClientResponseMappingSetter optionalBuilder) 11 | { 12 | return optionalBuilder.Use(new ResponseToEitherBuilderProvider()); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Mapping.LanguageExt/ResponseToEitherBuilderProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Transport; 2 | 3 | namespace NClient.Providers.Mapping.LanguageExt 4 | { 5 | /// The provider of the mapper that converts NClient responses into Either monad from LanguageExt. 6 | public class ResponseToEitherBuilderProvider : IResponseMapperProvider 7 | { 8 | /// Creates the mapper that converts NClient responses into Either monad from LanguageExt. 9 | /// Tools that help implement providers. 10 | public IResponseMapper Create(IToolset toolset) 11 | { 12 | return new ResponseToEitherBuilder(toolset); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Serialization.MessagePack/Enums/MIMEType.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Providers.Serialization.MessagePack 5 | { 6 | public enum MimeType 7 | { 8 | [Description("application/msgpack")] 9 | ProperType = 0, 10 | [Description("application/x-msgpack")] 11 | XType = 1, 12 | [Description("application/vnd.msgpack")] 13 | VendorType = 2 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Serialization.ProtobufNet/ProtobufNetSerializerSettings.cs: -------------------------------------------------------------------------------- 1 | using NClient.Common.Helpers; 2 | 3 | namespace NClient.Providers.Serialization.ProtobufNet 4 | { 5 | /// The container of settings for ProtobufNet serializer. 6 | public record ProtobufNetSerializerSettings 7 | { 8 | /// Gets supported content type. 9 | public string ContentTypeHeader { get; } = string.Empty; 10 | 11 | /// Initializes the container of settings for ProtobufNet serializer. 12 | /// The name of supported content type. 13 | public ProtobufNetSerializerSettings(string contentTypeHeader) 14 | { 15 | Ensure.IsNotNullOrEmpty(contentTypeHeader, nameof(contentTypeHeader)); 16 | 17 | ContentTypeHeader = contentTypeHeader; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Transport.RestSharp/Extensions/UseRestSharpResponseValidationExtensions.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Transport.RestSharp; 2 | using RestSharp; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient 6 | { 7 | public static class UseRestSharpResponseValidationExtensions 8 | { 9 | /// Sets default System.Net.Http validation the contents of the response received from transport. 10 | public static INClientResponseValidationSelector UseRestSharpResponseValidation( 11 | this INClientTransportResponseValidationSetter transportResponseValidationSetter) 12 | { 13 | return transportResponseValidationSetter.Use(new DefaultRestSharpResponseValidatorSettings()); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Transport.RestSharp/RestSharpTransport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using RestSharp; 5 | 6 | namespace NClient.Providers.Transport.RestSharp 7 | { 8 | internal class RestSharpTransport : ITransport 9 | { 10 | private readonly IRestClient _restClient; 11 | 12 | public TimeSpan Timeout => TimeSpan.FromMilliseconds(_restClient.Timeout); 13 | 14 | public RestSharpTransport(IRestClient restClient) 15 | { 16 | _restClient = restClient; 17 | } 18 | 19 | public async Task ExecuteAsync(IRestRequest transportRequest, CancellationToken cancellationToken) 20 | { 21 | cancellationToken.ThrowIfCancellationRequested(); 22 | 23 | return await _restClient.ExecuteAsync(transportRequest, cancellationToken).ConfigureAwait(false); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Transport.SystemNetHttp/Extensions/UseSystemNetHttpResponseValidationExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using NClient.Providers.Transport.SystemNetHttp; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient 6 | { 7 | public static class UseSystemNetHttpResponseValidationExtensions 8 | { 9 | /// Sets default System.Net.Http validation the contents of the response received from transport. 10 | public static INClientResponseValidationSelector UseSystemNetHttpResponseValidation( 11 | this INClientTransportResponseValidationSetter transportResponseValidationSetter) 12 | { 13 | return transportResponseValidationSetter.Use(new DefaultSystemNetHttpResponseValidatorSettings()); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Transport.SystemNetHttp/Models/HeaderDictionary.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.Extensions.Primitives; 4 | 5 | // ReSharper disable once CheckNamespace 6 | namespace NClient.Models 7 | { 8 | #pragma warning disable CS8644 9 | public class HeaderDictionary : Dictionary, IHeaderDictionary 10 | { 11 | public long? ContentLength { get; set; } 12 | 13 | public HeaderDictionary() 14 | { 15 | } 16 | 17 | public HeaderDictionary(IEnumerable> keyValuePairs) 18 | { 19 | foreach (var keyValuePair in keyValuePairs) 20 | { 21 | Add(keyValuePair.Key, keyValuePair.Value); 22 | } 23 | } 24 | } 25 | #pragma warning restore CS8644 26 | } 27 | -------------------------------------------------------------------------------- /src/NClient.Providers/NClient.Providers.Transport.SystemNetHttp/SystemNetHttpResponseBuilderProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | 3 | namespace NClient.Providers.Transport.SystemNetHttp 4 | { 5 | /// The provider that can create builder for transforming a System.Net.Http response to NClient response. 6 | public class SystemNetHttpResponseBuilderProvider : IResponseBuilderProvider 7 | { 8 | /// Creates builder for transforming a System.Net.Http response to NClient response. 9 | /// Tools that help implement providers. 10 | public IResponseBuilder Create(IToolset toolset) 11 | { 12 | return new SystemNetHttpResponseBuilder(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Loaders/FileLoader.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading.Tasks; 3 | 4 | namespace NClient.DotNetTool.Loaders 5 | { 6 | public class FileLoader : ISpecificationLoader 7 | { 8 | private readonly string _path; 9 | public FileLoader(string path) 10 | { 11 | _path = path; 12 | } 13 | 14 | public Task LoadAsync() 15 | { 16 | #if NETFRAMEWORK 17 | return Task.FromResult(File.ReadAllText(_path)); 18 | #else 19 | return File.ReadAllTextAsync(_path); 20 | #endif 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Loaders/ILoaderFactory.cs: -------------------------------------------------------------------------------- 1 | using NClient.DotNetTool.Options; 2 | 3 | namespace NClient.DotNetTool.Loaders 4 | { 5 | public interface ILoaderFactory 6 | { 7 | ISpecificationLoader Create(InterfaceGenerationOptions generationOptions); 8 | } 9 | } -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Loaders/ISpecificationLoader.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace NClient.DotNetTool.Loaders 4 | { 5 | public interface ISpecificationLoader 6 | { 7 | Task LoadAsync(); 8 | } 9 | } -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Loaders/LoaderFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.DotNetTool.Options; 3 | 4 | namespace NClient.DotNetTool.Loaders 5 | { 6 | public class LoaderFactory : ILoaderFactory 7 | { 8 | public ISpecificationLoader Create(InterfaceGenerationOptions generationOptions) 9 | { 10 | return Uri.TryCreate(generationOptions.Spec, UriKind.Absolute, out var uriResult) 11 | && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps) 12 | ? new NetworkLoader(uriResult) 13 | : new FileLoader(generationOptions.Spec); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Loaders/NetworkLoader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | 5 | namespace NClient.DotNetTool.Loaders 6 | { 7 | public class NetworkLoader : ISpecificationLoader 8 | { 9 | private readonly Uri _uri; 10 | 11 | public NetworkLoader(Uri uri) 12 | { 13 | _uri = uri; 14 | } 15 | 16 | public async Task LoadAsync() 17 | { 18 | using var client = new HttpClient(); 19 | using var responseMessage = await client.GetAsync(_uri); 20 | responseMessage.EnsureSuccessStatusCode(); 21 | return await responseMessage.Content.ReadAsStringAsync(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Logging/LogEvents.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace NClient.DotNetTool.Logging 4 | { 5 | public static class LogEvents 6 | { 7 | public static readonly EventId Done = new(id: 1000, nameof(Done)); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Logging/LoggerExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace NClient.DotNetTool.Logging 4 | { 5 | public static class LoggerExtensions 6 | { 7 | public static void LogDone(this ILogger logger, string message, params object[] args) 8 | { 9 | // ReSharper disable once TemplateIsNotCompileTimeConstantProblem 10 | logger.LogInformation(LogEvents.Done, message, args); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Options/CommonOptions.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | using Microsoft.Extensions.Logging; 3 | 4 | namespace NClient.DotNetTool.Options 5 | { 6 | public abstract class CommonOptions 7 | { 8 | protected CommonOptions(LogLevel logLevel) 9 | { 10 | LogLevel = logLevel; 11 | } 12 | 13 | [Option(Default = LogLevel.Information)] 14 | public LogLevel LogLevel { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Savers/FileSaver.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading.Tasks; 3 | 4 | namespace NClient.DotNetTool.Savers 5 | { 6 | public class FileSaver : ISaver 7 | { 8 | public async Task SaveAsync(string content, string output) 9 | { 10 | if (File.Exists(output)) 11 | File.Delete(output); 12 | 13 | #if NETFRAMEWORK 14 | File.WriteAllText(output, content); 15 | await Task.CompletedTask.ConfigureAwait(false); 16 | #else 17 | await File.WriteAllTextAsync(output, content); 18 | #endif 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/NClient.Tools/NClient.DotNetTool/Savers/ISaver.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace NClient.DotNetTool.Savers 4 | { 5 | public interface ISaver 6 | { 7 | Task SaveAsync(string content, string output); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Auth/IAnonymousAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that the class or method that this attribute is applied to does not require authorization. 6 | public interface IAnonymousAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Auth/IAuthorizedAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that the class or method that this attribute is applied to requires the specified authorization. 6 | public interface IAuthorizedAttribute 7 | { 8 | /// Gets the policy name that determines access to the resource. 9 | string? Policy { get; } 10 | 11 | /// Gets or sets a comma delimited list of roles that are allowed to access the resource. 12 | string? Roles { get; set; } 13 | 14 | /// Gets or sets a comma delimited list of schemes from which user information is constructed. 15 | string? AuthenticationSchemes { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Common/INameProviderAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Interface for attributes which can supply a name for attribute. 6 | public interface INameProviderAttribute 7 | { 8 | /// Gets or sets the route name. The route name can be used to generate a link using a specific route, instead 9 | /// of relying on selection of a route based on the given set of route values. 10 | string? Name { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Common/IOrderProviderAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Interface for attributes which can supply an order for attribute. 6 | public interface IOrderProviderAttribute 7 | { 8 | /// Gets the route order. The order determines the order of route execution. Routes with a lower 9 | /// order value are tried first. When a route doesn't specify a value, it gets a default value of 0. 10 | /// A null value for the Order property means that the user didn't specify an explicit order for the route. 11 | public int Order { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Common/IPathProviderAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Interface for attributes which can supply a route template for attribute. 6 | public interface IPathProviderAttribute 7 | { 8 | /// Gets or sets a route template. 9 | string? Path { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/IHeaderAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Annotations.Http 2 | { 3 | /// Specifies that a method/methods should be use the request header. 4 | public interface IHeaderAttribute : IMetadataAttribute 5 | { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/IHttpFacadeAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Annotations.Http 2 | { 3 | /// Indicates that a type and all derived types are used to serve HTTP API responses. 4 | public interface IHttpFacadeAttribute : IFacadeAttribute 5 | { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Methods/IDeleteMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP DELETE method. 6 | public interface IDeleteMethodAttribute : IDeleteOperationAttribute, IOrderProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Methods/IGetMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP GET method. 6 | public interface IGetMethodAttribute : IReadOperationAttribute, IOrderProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Methods/IHeadMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP HEAD method. 6 | public interface IHeadMethodAttribute : ICheckOperationAttribute, IOrderProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Methods/IOptionsMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP OPTIONS method. 6 | public interface IOptionsMethodAttribute : IInfoOperationAttribute, IOrderProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Methods/IPatchMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | // ReSharper disable once EmptyNamespace 3 | 4 | namespace NClient.Annotations.Http 5 | { 6 | #if !NETSTANDARD2_0 7 | /// Identifies an action that supports the HTTP PATCH method. 8 | public interface IPatchMethodAttribute : IPartialUpdateOperationAttribute, IOrderProviderAttribute 9 | { 10 | } 11 | #endif 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Methods/IPostMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP POST method. 6 | public interface IPostMethodAttribute : ICreateOperationAttribute, IOrderProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Methods/IPutMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP PUT method. 6 | public interface IPutMethodAttribute : IUpdateOperationAttribute, IOrderProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Parameters/IBodyParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a parameter should be bound using the request body. 6 | public interface IBodyParamAttribute : IContentParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Parameters/IFormParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a parameter or property should be bound using form-data in the request body. 6 | public interface IFormParamAttribute : IContentParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Parameters/IHeaderParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a parameter should be bound using the request headers. 6 | public interface IHeaderParamAttribute : IMetadataParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Parameters/IQueryParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a parameter should be bound using the request query string. 6 | public interface IQueryParamAttribute : IPropertyParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Http/Parameters/IRouteParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a parameter should be bound using route-data from the current request. 6 | public interface IRouteParamAttribute : IPathParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/IFacadeAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Annotations 2 | { 3 | /// Indicates that a type and all derived types are used to serve API responses or/and to send requests. 4 | public interface IFacadeAttribute 5 | { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/IMetadataAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Annotations 2 | { 3 | /// Specifies that a method/methods should be use the request metadata. 4 | public interface IMetadataAttribute : INameProviderAttribute 5 | { 6 | /// Gets metadata value. 7 | string Value { get; } 8 | 9 | /// Gets metadata value. 10 | new string Name { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/IOverrideAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Annotations 2 | { 3 | /// An attribute indicating that the attributes of the overridden member will be inherited. 4 | public interface IOverrideAttribute 5 | { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/IResponseAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace NClient.Annotations 5 | { 6 | /// A filter that specifies the type of the value and status code returned by the action. 7 | public interface IResponseAttribute 8 | { 9 | /// Gets or sets the type of the value returned by an action. 10 | Type Type { get; } 11 | 12 | /// Gets or sets the HTTP status code of the response. 13 | HttpStatusCode StatusCode { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/ITimeoutAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Annotations 2 | { 3 | /// Identifies an action that restrict by timeout. 4 | public interface ITimeoutAttribute 5 | { 6 | /// The timeout value in milliseconds. 7 | double Milliseconds { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Operations/ICheckOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports CHECK operation. 6 | /// The CHECK operation asks for a response identical to a READ operation, but without the response content. 7 | public interface ICheckOperationAttribute : IOperationAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Operations/ICreateOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports CREATE operation. 6 | /// The CREATE operation submit an entity to the specified resource, often causing a change in state or side effects on the server. 7 | public interface ICreateOperationAttribute : IOperationAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Operations/ICustomOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports custom operation. 6 | public interface ICustomOperationAttribute : IOperationAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Operations/IDeleteOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports DELETE operation. 6 | /// The DELETE operation deletes the specified resource. 7 | public interface IDeleteOperationAttribute : IOperationAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Operations/IInfoOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports INFO operation. 6 | /// The INFO operation describes the communication options for the target resource. 7 | public interface IInfoOperationAttribute : IOperationAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Operations/IOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports a given set of operations. 6 | public interface IOperationAttribute : INameProviderAttribute, IPathProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Operations/IPartialUpdateOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports PartialUpdate operation. 6 | /// The PartialUpdate operation applies partial modifications to a resource. 7 | public interface IPartialUpdateOperationAttribute : IOperationAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Operations/IReadOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports READ operation. 6 | /// The READ operation requests a representation of the specified resource. Requests using READ should only retrieve data. 7 | public interface IReadOperationAttribute : IOperationAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Operations/IUpdateOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports UPDATE operation. 6 | /// The UPDATE operation replaces all current representations of the target resource with the request payload. 7 | public interface IUpdateOperationAttribute : IOperationAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Parameters/IContentParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that a parameter should be pass a data bytes transmitted in an transport message. Only one parameter is allowed. 6 | public interface IContentParamAttribute : IParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Parameters/IMetadataParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that a parameter should be pass an additional information in an transport message. Many parameters are allowed. 6 | public interface IMetadataParamAttribute : IParamAttribute, INameProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Parameters/IParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that a parameter should be pass data in an transport message. 6 | public interface IParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Parameters/IPathParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that a parameter should be pass data in an transport message path. Many parameters are allowed. 6 | public interface IPathParamAttribute : IParamAttribute, INameProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Parameters/IPropertyParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that a parameter should be pass an data in an transport message. Many parameters are allowed. 6 | public interface IPropertyParamAttribute : IParamAttribute, INameProviderAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Versioning/IToVersionAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Represents the metadata that describes the API version-specific implementation of a service. 6 | public interface IToVersionAttribute 7 | { 8 | /// Gets the API version defined by the attribute. 9 | string Version { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Versioning/IUseVersionAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Represents the metadata that describes the API version associated used by the client. 6 | public interface IUseVersionAttribute 7 | { 8 | /// Gets the API version defined by the attribute. 9 | string Version { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Annotations/Versioning/IVersionAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Represents the metadata that describes the API version associated with a service. 6 | public interface IVersionAttribute 7 | { 8 | /// Gets the API version defined by the attribute. 9 | string Version { get; } 10 | 11 | /// Gets or sets a value indicating whether the specified set of API versions are deprecated. 12 | /// True if the specified set of API versions are deprecated; otherwise, false. The default value is false. 13 | bool Deprecated { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Building/Configuration/Handling/INClientHandlingSelector.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient 4 | { 5 | /// Selector for configuring handling on the selected client layer. 6 | /// The type of request that is used in the transport implementation. 7 | /// The type of response that is used in the transport implementation. 8 | public interface INClientHandlingSelector 9 | { 10 | /// Select transport layer. 11 | INClientTransportHandlingSetter ForTransport(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Building/Configuration/Mapping/INClientResponseMappingSelector.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient 4 | { 5 | /// Selector for configuring mapping on the selected client layer. 6 | /// The type of request that is used in the transport implementation. 7 | /// The type of response that is used in the transport implementation. 8 | public interface INClientResponseMappingSelector 9 | { 10 | /// Select NClient layer. 11 | INClientResponseMappingSetter ForClient(); 12 | 13 | /// Select transport layer. 14 | INClientTransportResponseMappingSetter ForTransport(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Building/Configuration/Validation/INClientResponseValidationSelector.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient 4 | { 5 | /// Selector for configuring validation on the selected client layer. 6 | /// The type of request that is used in the transport implementation. 7 | /// The type of response that is used in the transport implementation. 8 | public interface INClientResponseValidationSelector 9 | { 10 | /// Select transport layer. 11 | INClientTransportResponseValidationSetter ForTransport(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Building/Factory/INClientFactoryApiBuilder.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Api; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient 5 | { 6 | /// Setter a custom provider of the request builder that turns a method call into a request. 7 | public interface INClientFactoryApiBuilder 8 | { 9 | /// Sets a custom provider of the request builder that turns a method call into a request. 10 | /// The provider of the request builder that turns a method call into a request. 11 | INClientFactoryTransportBuilder UsingCustomApi(IRequestBuilderProvider requestBuilderProvider); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Building/Factory/INClientFactorySerializationBuilder.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Serialization; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient 5 | { 6 | /// Setter a custom used to create instances of .. 7 | public interface INClientFactorySerializationBuilder 8 | { 9 | /// Sets custom used to create instances of . 10 | /// The provider that can create instances of . 11 | INClientFactoryOptionalBuilder UsingCustomSerializer(ISerializerProvider serializerProvider); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Building/INClientApiBuilder.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Api; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient 5 | { 6 | /// Setter a custom provider of the request builder that turns a method call into a request. 7 | public interface INClientApiBuilder where TClient : class 8 | { 9 | /// Sets a custom provider of the request builder that turns a method call into a request. 10 | /// The provider of the request builder that turns a method call into a request. 11 | INClientTransportBuilder UsingCustomApi(IRequestBuilderProvider requestBuilderProvider); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Building/INClientSerializationBuilder.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Serialization; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient 5 | { 6 | /// Setter a custom used to create instances of .. 7 | public interface INClientSerializationBuilder where TClient : class 8 | { 9 | /// Sets custom used to create instances of . 10 | /// The provider that can create instances of . 11 | INClientOptionalBuilder UsingCustomSerializer(ISerializerProvider serializerProvider); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/INClient.cs: -------------------------------------------------------------------------------- 1 | namespace NClient 2 | { 3 | /// Interface used to get a response and to set specific policies using extension methods. 4 | public interface INClient 5 | { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/INClientFactoryBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace NClient 2 | { 3 | /// A builder abstraction used to create the client factory with custom providers. 4 | public interface INClientFactoryBuilder 5 | { 6 | /// Sets the factory name. 7 | /// The factory name. 8 | INClientFactoryApiBuilder For(string factoryName); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Invocation/IMethodInvocation.cs: -------------------------------------------------------------------------------- 1 | using NClient.Invocation; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient 5 | { 6 | /// Information about the invocation of the client's method. 7 | public interface IMethodInvocation 8 | { 9 | /// Gets method information. 10 | public IMethod Method { get; } 11 | 12 | /// Gets values of the arguments in the client method call. 13 | object[] Arguments { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Invocation/IMethodParam.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.Annotations; 3 | 4 | namespace NClient.Invocation 5 | { 6 | /// Information about the method parameter. 7 | public interface IMethodParam 8 | { 9 | /// Gets parameter name. 10 | string Name { get; } 11 | 12 | /// Gets parameter type. 13 | Type Type { get; } 14 | 15 | /// Gets parameter attribute. 16 | IParamAttribute Attribute { get; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Invocation/MethodInvocation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using NClient.Invocation; 4 | 5 | // ReSharper disable once CheckNamespace 6 | namespace NClient 7 | { 8 | internal class MethodInvocation : IMethodInvocation 9 | { 10 | public IMethod Method { get; } 11 | public object[] Arguments { get; } 12 | 13 | public MethodInvocation(IMethod method, IEnumerable methodArguments) 14 | { 15 | Method = method; 16 | Arguments = methodArguments.ToArray(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Invocation/MethodParam.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.Annotations; 3 | 4 | namespace NClient.Invocation 5 | { 6 | internal class MethodParam : IMethodParam 7 | { 8 | public string Name { get; } 9 | public Type Type { get; } 10 | public IParamAttribute Attribute { get; } 11 | 12 | public MethodParam(string name, Type type, IParamAttribute attribute) 13 | { 14 | Name = name; 15 | Type = type; 16 | Attribute = attribute; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Api/IRequestBuilderProvider.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Api 2 | { 3 | /// The provider of the request builder that turns a method call into a request. 4 | public interface IRequestBuilderProvider 5 | { 6 | /// Creates the request builder that turns a method call into a request. 7 | /// Tools that help implement providers. 8 | IRequestBuilder Create(IToolset toolset); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Authorization/AccessToken.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Authorization 2 | { 3 | /// The access token for client authorization. 4 | public class AccessToken : IAccessToken 5 | { 6 | /// The scheme to use for authorization. 7 | public string Scheme { get; } 8 | 9 | /// The access token value. 10 | public string Value { get; } 11 | 12 | /// Creates the access token for client authorization. 13 | /// The scheme to use for authorization. 14 | /// The access token value. 15 | public AccessToken(string scheme, string value) 16 | { 17 | Scheme = scheme; 18 | Value = value; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Authorization/IAccessToken.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Authorization 2 | { 3 | /// The access token for client authorization. 4 | public interface IAccessToken 5 | { 6 | /// The scheme to use for authorization. 7 | string Scheme { get; } 8 | 9 | /// The access token value. 10 | string Value { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Authorization/IAccessTokens.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Providers.Authorization 4 | { 5 | /// Provides the authentication interface for retrieving access tokens for client authentication. 6 | public interface IAccessTokens 7 | { 8 | /// Returns an access token string that is associated with the specified URI. 9 | /// The that the client is providing authentication for. 10 | IAccessToken? TryGet(Uri uri); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Authorization/IAuthorization.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace NClient.Providers.Authorization 5 | { 6 | /// Provides the authentication interface for retrieving access tokens for client authentication. 7 | public interface IAuthorization 8 | { 9 | /// Returns an access tokens for client authentication. 10 | Task TryGetAccessTokensAsync(CancellationToken cancellationToken); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Authorization/IAuthorizationProvider.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Authorization 2 | { 3 | /// Provides the authentication interface for client authentication. 4 | public interface IAuthorizationProvider 5 | { 6 | /// Returns a authentication for client. 7 | IAuthorization Create(IToolset toolset); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Authorization/SingleAccessToken.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Providers.Authorization 4 | { 5 | internal class SingleAccessToken : IAccessTokens 6 | { 7 | private readonly IAccessToken _accessToken; 8 | 9 | public SingleAccessToken(IAccessToken accessToken) 10 | { 11 | _accessToken = accessToken; 12 | } 13 | 14 | public IAccessToken TryGet(Uri uri) 15 | { 16 | return _accessToken; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Handling/IClientHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Providers.Handling 4 | { 5 | /// The providers creating handlers that provide custom functionality to handling transport requests and responses. 6 | /// The type of request that is used in the transport implementation. 7 | /// The type of response that is used in the transport implementation. 8 | public interface IClientHandlerProvider 9 | { 10 | /// Creates the providers creating handlers that provide custom functionality to handling transport requests and responses. 11 | /// Tools that help implement providers. 12 | IClientHandler Create(IToolset toolset); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Handling/IClientHandlerSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Providers.Handling 4 | { 5 | /// Settings for handling operations that handles the transport messages. 6 | /// The type of request that is used in the transport implementation. 7 | /// The type of response that is used in the transport implementation. 8 | public interface IClientHandlerSettings 9 | { 10 | /// Gets the function that will be executed before a request. 11 | Func BeforeRequest { get; } 12 | 13 | /// Gets the function that will be executed after a request. 14 | Func AfterResponse { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Mapping/IResponseMapperProvider.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Mapping 2 | { 3 | /// The provider of a mapper that converts transport responses into custom results. 4 | /// The type of request that is used in the transport implementation. 5 | /// The type of response that is used in the transport implementation. 6 | public interface IResponseMapperProvider 7 | { 8 | /// Creates the mapper that converts transport responses into custom results. 9 | /// Tools that help implement providers. 10 | IResponseMapper Create(IToolset toolset); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Resilience/IResiliencePolicyProvider.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Providers.Resilience 4 | { 5 | /// A provider abstraction that can create a transient exception handling policies. 6 | /// The type of request that is used in the transport implementation. 7 | /// The type of response that is used in the transport implementation. 8 | public interface IResiliencePolicyProvider 9 | { 10 | /// Creates and configures an instance of transient exception handling policy. 11 | /// Tools that help implement providers. 12 | IResiliencePolicy Create(IToolset toolset); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Serialization/ISerializerProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace NClient.Providers.Serialization 4 | { 5 | /// A provider abstraction for a component that can create instances. 6 | public interface ISerializerProvider 7 | { 8 | /// Creates and configures an instance of instance. 9 | /// Optional logger. If it is not passed, then logs will not be written. 10 | ISerializer Create(ILogger logger); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Tools/IToolSet.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using NClient.Providers.Serialization; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient.Providers 6 | { 7 | /// Tools that help implement providers. 8 | public interface IToolset 9 | { 10 | /// Gets the serializer that provides functionality to serialize objects or value types to serialized string and to deserialize serialized string into objects or value types. 11 | ISerializer Serializer { get; } 12 | 13 | /// Gets the logger used to perform logging. 14 | ILogger Logger { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Tools/ToolSet.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using NClient.Providers.Serialization; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient.Providers 6 | { 7 | internal class Toolset : IToolset 8 | { 9 | public ISerializer Serializer { get; } 10 | 11 | public ILogger Logger { get; } 12 | 13 | public Toolset(ISerializer serializer, ILogger logger) 14 | { 15 | Serializer = serializer; 16 | Logger = logger; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/Common/IContent.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient.Providers.Transport 6 | { 7 | /// Response content. 8 | public interface IContent 9 | { 10 | /// Gets stream representation of response content 11 | Stream Stream { get; } 12 | 13 | /// Gets response content encoding. 14 | Encoding? Encoding { get; } 15 | 16 | /// Gets metadata returned by server with the response content. 17 | IMetadataContainer Metadatas { get; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/Common/IMetadata.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Providers.Transport 4 | { 5 | /// Represents additional information of a request or response. 6 | public interface IMetadata 7 | { 8 | /// Gets metadata name. 9 | string Name { get; } 10 | 11 | /// Gets metadata value. 12 | string Value { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/Common/IMetadataContainer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Providers.Transport 5 | { 6 | /// Represents the collection of additional information of a request or response. 7 | public interface IMetadataContainer : IEnumerable>> 8 | { 9 | /// Returns metadata by name. 10 | /// The metadata name. 11 | IEnumerable Get(string name); 12 | 13 | /// Returns metadata by name. 14 | /// The metadata name. 15 | IEnumerable GetValueOrDefault(string name); 16 | 17 | /// Adds metadata to the collection. 18 | /// The metadata. 19 | void Add(IMetadata metadata); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/Common/IParameter.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Providers.Transport 4 | { 5 | /// Represents a parameter of a request or response. 6 | public interface IParameter 7 | { 8 | /// Gets parameter name. 9 | string Name { get; } 10 | 11 | /// Gets parameter value. 12 | object? Value { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/Common/IPipelineCanceller.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Transport.Common 2 | { 3 | public interface IPipelineCanceller 4 | { 5 | void Renew(); 6 | void Cancel(); 7 | bool IsCancellationRequested { get; } 8 | void Dispose(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/Common/Metadata.cs: -------------------------------------------------------------------------------- 1 | using NClient.Common.Helpers; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Providers.Transport 5 | { 6 | /// Represents additional information of a request or response. 7 | public record Metadata : IMetadata 8 | { 9 | /// Gets metadata name. 10 | public string Name { get; } 11 | 12 | /// Gets metadata value. 13 | public string Value { get; } 14 | 15 | public Metadata(string name, string value) 16 | { 17 | Ensure.IsNotNullOrEmpty(name, nameof(name)); 18 | Ensure.IsNotNullOrEmpty(value, nameof(value)); 19 | 20 | Name = name; 21 | Value = value; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/Common/Parameter.cs: -------------------------------------------------------------------------------- 1 | using NClient.Common.Helpers; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Providers.Transport 5 | { 6 | /// Represents a parameter of a request or response. 7 | public class Parameter : IParameter 8 | { 9 | /// Gets parameter name. 10 | public string Name { get; } 11 | 12 | /// Gets parameter value. 13 | public object? Value { get; } 14 | 15 | public Parameter(string name, object? value) 16 | { 17 | Ensure.IsNotNullOrEmpty(name, nameof(name)); 18 | 19 | Name = name; 20 | Value = value; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/Context/IResponseContext.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Providers.Transport 4 | { 5 | /// The context containing transport request and response. 6 | /// The type of request that is used in the transport implementation. 7 | /// The type of response that is used in the transport implementation. 8 | public interface IResponseContext 9 | { 10 | /// Gets transport request. 11 | TRequest Request { get; } 12 | 13 | /// Gets transport response. 14 | TResponse Response { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/IResponseBuilderProvider.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Transport 2 | { 3 | /// The provider that can create builder for transforming a transport response to NClient response. 4 | /// The type of request that is used in the transport implementation. 5 | /// The type of response that is used in the transport implementation. 6 | public interface IResponseBuilderProvider 7 | { 8 | /// Creates builder for transforming a transport response to NClient response. 9 | /// Tools that help implement providers. 10 | IResponseBuilder Create(IToolset toolset); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/ITransportProvider.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Transport 2 | { 3 | /// The provider for a component that can create transport. 4 | /// The type of request that is used in the transport implementation. 5 | /// The type of response that is used in the transport implementation. 6 | public interface ITransportProvider 7 | { 8 | /// Creates transport. 9 | /// Tools that help implement providers. 10 | ITransport Create(IToolset toolset); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/ITransportRequestBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | // ReSharper disable once UnusedTypeParameter 5 | namespace NClient.Providers.Transport 6 | { 7 | /// The builder for transforming a NClient request to transport request. 8 | /// The type of request that is used in the transport implementation. 9 | /// The type of response that is used in the transport implementation. 10 | public interface ITransportRequestBuilder 11 | { 12 | /// Builds transport request. 13 | /// The container for data used to make requests. 14 | /// The cancellation token. 15 | Task BuildAsync(IRequest request, CancellationToken cancellationToken); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Transport/Requests/RequestType.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable ConvertToConstant.Global 2 | // ReSharper disable once CheckNamespace 3 | 4 | namespace NClient.Providers.Transport 5 | { 6 | public enum RequestType 7 | { 8 | Custom, 9 | Info, 10 | Read, 11 | Check, 12 | Create, 13 | Update, 14 | PartialUpdate, 15 | Delete 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.Abstractions/Providers/Validation/IResponseValidatorProvider.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Providers.Validation 4 | { 5 | /// The provider of response validator for validation the contents of the response received from transport. 6 | /// The type of request that is used in the transport implementation. 7 | /// The type of response that is used in the transport implementation. 8 | public interface IResponseValidatorProvider 9 | { 10 | /// Creates the response validator for validation the contents of the response received from transport. 11 | /// Tools that help implement providers. 12 | IResponseValidator Create(IToolset toolset); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Auth/AnonymousAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Annotations.Auth 4 | { 5 | /// Specifies that the class or method that this attribute is applied to does not require authorization. 6 | [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] 7 | public class AnonymousAttribute : Attribute, IAnonymousAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/FacadeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Indicates that a type and all derived types are used to serve API responses or/and to send requests. 6 | [AttributeUsage(AttributeTargets.Interface, AllowMultiple = false, Inherited = true)] 7 | public class FacadeAttribute : Attribute, IFacadeAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/HeaderAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a method/methods should be use the request header. 6 | [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] 7 | public class HeaderAttribute : MetadataAttribute, IHeaderAttribute 8 | { 9 | /// Initializes a new with the given header. 10 | /// The header name. 11 | /// The header value. 12 | public HeaderAttribute(string name, string value) : base(name, value) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/HttpFacadeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Indicates that a type and all derived types are used to serve HTTP API responses. 6 | /// Controllers that implement an interface with this attribute will inherit from . 7 | [AttributeUsage(AttributeTargets.Interface, AllowMultiple = false, Inherited = true)] 8 | public class HttpFacadeAttribute : FacadeAttribute, IHttpFacadeAttribute 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Methods/DeleteMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP DELETE method. 6 | public class DeleteMethodAttribute : DeleteOperationAttribute, IDeleteMethodAttribute 7 | { 8 | public int Order { get; set; } 9 | 10 | /// Initializes a new with the given path template. 11 | /// The path template. 12 | public DeleteMethodAttribute(string? path = null) : base(path) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Methods/GetMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP GET method. 6 | public class GetMethodAttribute : ReadOperationAttribute, IGetMethodAttribute 7 | { 8 | public int Order { get; set; } 9 | 10 | /// Initializes a new with the given path template. 11 | /// The path template. 12 | public GetMethodAttribute(string? path = null) : base(path) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Methods/HeadMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP HEAD method. 6 | public class HeadMethodAttribute : CheckOperationAttribute, IHeadMethodAttribute 7 | { 8 | public int Order { get; set; } 9 | 10 | /// Initializes a new with the given path template. 11 | /// The path template. 12 | public HeadMethodAttribute(string? path = null) : base(path) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Methods/OptionsMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP OPTIONS method. 6 | public class OptionsMethodAttribute : InfoOperationAttribute, IOptionsMethodAttribute 7 | { 8 | public int Order { get; set; } 9 | 10 | /// Initializes a new with the given path template. 11 | /// The path template. 12 | public OptionsMethodAttribute(string? path = null) : base(path) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Methods/PatchMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | // ReSharper disable once EmptyNamespace 3 | 4 | namespace NClient.Annotations.Http 5 | { 6 | #if !NETSTANDARD2_0 7 | /// Identifies an action that supports the HTTP PATCH method. 8 | public class PatchMethodAttribute : PartialUpdateOperationAttribute, IPatchMethodAttribute 9 | { 10 | public int Order { get; set; } 11 | 12 | /// Initializes a new with the given path template. 13 | /// The path template. 14 | public PatchMethodAttribute(string? path = null) : base(path) 15 | { 16 | } 17 | } 18 | #endif 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Methods/PostMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP POST method. 6 | public class PostMethodAttribute : CreateOperationAttribute, IPostMethodAttribute 7 | { 8 | public int Order { get; set; } 9 | 10 | /// Initializes a new with the given path template. 11 | /// The path template. 12 | public PostMethodAttribute(string? path = null) : base(path) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Methods/PutMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Identifies an action that supports the HTTP PUT method. 6 | public class PutMethodAttribute : UpdateOperationAttribute, IPutMethodAttribute 7 | { 8 | public int Order { get; set; } 9 | 10 | /// Initializes a new with the given path template. 11 | /// The path template. 12 | public PutMethodAttribute(string? path = null) : base(path) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Parameters/BodyParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a parameter should be bound using the request body. 6 | public class BodyParamAttribute : ContentParamAttribute, IBodyParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Parameters/FormParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a parameter or property should be bound using form-data in the request body. 6 | public class FormParamAttribute : ContentParamAttribute, IFormParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Parameters/HeaderParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a parameter should be bound using the request headers. 6 | public class HeaderParamAttribute : MetadataParamAttribute, IHeaderParamAttribute 7 | { 8 | /// Initializes a new . 9 | public HeaderParamAttribute() 10 | { 11 | } 12 | 13 | /// Initializes a new with the given header parameter. 14 | /// The header parameter name. 15 | public HeaderParamAttribute(string name) : base(name) 16 | { 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Parameters/QueryParamAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Annotations.Http 5 | { 6 | /// Specifies that a parameter should be bound using the request query string. 7 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] 8 | public class QueryParamAttribute : PropertyParamAttribute, IQueryParamAttribute 9 | { 10 | /// Initializes a new . 11 | public QueryParamAttribute() 12 | { 13 | } 14 | 15 | /// Initializes a new with the given query parameter. 16 | /// The query parameter name. 17 | public QueryParamAttribute(string name) : base(name) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Http/Parameters/RouteParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations.Http 4 | { 5 | /// Specifies that a parameter should be bound using route-data from the current request. 6 | public class RouteParamAttribute : PathParamAttribute, IRouteParamAttribute 7 | { 8 | /// Initializes a new . 9 | public RouteParamAttribute() 10 | { 11 | } 12 | 13 | /// Initializes a new with the given route parameter. 14 | /// The route parameter name. 15 | public RouteParamAttribute(string name) : base(name) 16 | { 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Operations/CheckOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports CHECK operation. 6 | /// The CHECK operation asks for a response identical to a READ operation, but without the response content. 7 | public class CheckOperationAttribute : OperationAttribute, ICheckOperationAttribute 8 | { 9 | /// Initializes a new with the given path template. 10 | /// The path template. 11 | public CheckOperationAttribute(string? path = null) : base(path) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Operations/CreateOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports CREATE operation. 6 | /// The CREATE operation submit an entity to the specified resource, often causing a change in state or side effects on the server. 7 | public class CreateOperationAttribute : OperationAttribute, ICreateOperationAttribute 8 | { 9 | /// Initializes a new with the given path template. 10 | /// The path template. 11 | public CreateOperationAttribute(string? path = null) : base(path) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Operations/CustomOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports custom operation. 6 | public class CustomOperationAttribute : OperationAttribute, ICustomOperationAttribute 7 | { 8 | /// Initializes a new with the given path template. 9 | /// The path template. 10 | public CustomOperationAttribute(string? path = null) : base(path) 11 | { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Operations/DeleteOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports DELETE operation. 6 | /// The DELETE operation deletes the specified resource. 7 | public class DeleteOperationAttribute : OperationAttribute, IDeleteOperationAttribute 8 | { 9 | /// Initializes a new with the given path template. 10 | /// The path template. 11 | public DeleteOperationAttribute(string? path = null) : base(path) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Operations/InfoOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports INFO operation. 6 | /// The INFO operation describes the communication options for the target resource. 7 | public class InfoOperationAttribute : OperationAttribute, IInfoOperationAttribute 8 | { 9 | /// Initializes a new with the given path template. 10 | /// The path template. 11 | public InfoOperationAttribute(string? path = null) : base(path) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Operations/OperationAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Annotations 5 | { 6 | /// Identifies an action that supports a given set of operations. 7 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] 8 | public abstract class OperationAttribute : Attribute, IOperationAttribute 9 | { 10 | /// Gets or sets the route name. The route name can be used to generate a link using a specific route, instead 11 | /// of relying on selection of a route based on the given set of route values. 12 | public string? Name { get; set; } 13 | 14 | /// Gets or sets a route template. 15 | public string? Path { get; set; } 16 | 17 | protected OperationAttribute(string? path = null) 18 | { 19 | Path = path; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Operations/PartialUpdateOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports PartialUpdate operation. 6 | /// The PartialUpdate operation applies partial modifications to a resource. 7 | public class PartialUpdateOperationAttribute : OperationAttribute, IPartialUpdateOperationAttribute 8 | { 9 | /// Initializes a new with the given path template. 10 | /// The path template. 11 | public PartialUpdateOperationAttribute(string? path = null) : base(path) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Operations/ReadOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports READ operation. 6 | /// The READ operation requests a representation of the specified resource. Requests using READ should only retrieve data. 7 | public class ReadOperationAttribute : OperationAttribute, IReadOperationAttribute 8 | { 9 | /// Initializes a new with the given path template. 10 | /// The path template. 11 | public ReadOperationAttribute(string? path = null) : base(path) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Operations/UpdateOperationAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that supports UPDATE operation. 6 | /// The UPDATE operation replaces all current representations of the target resource with the request payload. 7 | public class UpdateOperationAttribute : OperationAttribute, IUpdateOperationAttribute 8 | { 9 | /// Initializes a new with the given path template. 10 | /// The path template. 11 | public UpdateOperationAttribute(string? path = null) : base(path) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/OverrideAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// An attribute indicating that the attributes of the overridden member will be inherited. 6 | [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] 7 | public class OverrideAttribute : Attribute, IOverrideAttribute 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Parameters/ContentParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that a parameter should be pass a data bytes transmitted in an transport message. Only one parameter is allowed. 6 | public class ContentParamAttribute : ParamAttribute, IContentParamAttribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Parameters/MetadataParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that a parameter should be pass an additional information in an transport message. Many parameters are allowed. 6 | public class MetadataParamAttribute : ParamAttribute, IMetadataParamAttribute 7 | { 8 | /// Gets or sets parameter name. 9 | public string? Name { get; set; } 10 | 11 | /// Initializes a new . 12 | public MetadataParamAttribute() 13 | { 14 | } 15 | 16 | /// Initializes a new with the given metadata parameter. 17 | /// The metadata parameter name. 18 | public MetadataParamAttribute(string name) 19 | { 20 | Name = name; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Parameters/ParamAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Annotations 5 | { 6 | /// Specifies that a parameter should be pass data in an transport message. 7 | [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] 8 | public abstract class ParamAttribute : Attribute, IParamAttribute 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Parameters/PathParamAttribute.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Specifies that a parameter should be pass data in an transport message path. Many parameters are allowed. 6 | public class PathParamAttribute : ParamAttribute, IPathParamAttribute 7 | { 8 | /// Gets or sets parameter name. 9 | public string? Name { get; set; } 10 | 11 | /// Initializes a new . 12 | public PathParamAttribute() 13 | { 14 | } 15 | 16 | /// Initializes a new with the given path parameter. 17 | /// The path parameter name. 18 | public PathParamAttribute(string name) 19 | { 20 | Name = name; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/TimeoutAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Annotations 4 | { 5 | /// Identifies an action that restrict by timeout. 6 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = true)] 7 | public class TimeoutAttribute : Attribute, ITimeoutAttribute 8 | { 9 | /// The timeout value in milliseconds. 10 | public double Milliseconds { get; } 11 | 12 | /// Initializes a new with the given milliseconds value. 13 | /// The timeout value in milliseconds. 14 | public TimeoutAttribute(double milliseconds) 15 | { 16 | Milliseconds = milliseconds; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Annotations/Versioning/ToVersionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.Common.Helpers; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient.Annotations 6 | { 7 | /// Represents the metadata that describes the API version-specific implementation of a service. 8 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)] 9 | public class ToVersionAttribute : Attribute, IToVersionAttribute 10 | { 11 | /// Gets the API version defined by the attribute. 12 | public string Version { get; } 13 | 14 | /// Initializes a new instance of the class. 15 | /// The API version. 16 | public ToVersionAttribute(string version) 17 | { 18 | Ensure.IsNotNullOrEmpty(version, nameof(version)); 19 | 20 | Version = version; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/NClient/NClient.AspNetCore/Controllers/Models/NClientControllerInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.AspNetCore.Controllers.Models 4 | { 5 | internal class NClientControllerInfo 6 | { 7 | public Type InterfaceType { get; } 8 | public Type ControllerType { get; } 9 | 10 | public NClientControllerInfo(Type interfaceType, Type controllerType) 11 | { 12 | InterfaceType = interfaceType; 13 | ControllerType = controllerType; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.AspNetCore/Controllers/Models/VirtualControllerInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.AspNetCore.Controllers.Models 4 | { 5 | internal class VirtualControllerInfo 6 | { 7 | public Type Type { get; } 8 | public Type ControllerType { get; } 9 | 10 | public VirtualControllerInfo(Type type, Type controllerType) 11 | { 12 | Type = type; 13 | ControllerType = controllerType; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NClient/NClient.AspNetCore/Controllers/VirtualControllerFeatureProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Microsoft.AspNetCore.Mvc.Controllers; 3 | 4 | namespace NClient.AspNetCore.Controllers 5 | { 6 | internal class VirtualControllerFeatureProvider : ControllerFeatureProvider 7 | { 8 | protected override bool IsController(TypeInfo typeInfo) 9 | { 10 | if (ControllerQualifier.IsNClientController(typeInfo)) 11 | return false; 12 | 13 | if (ControllerQualifier.IsNClientVirtualController(typeInfo)) 14 | return true; 15 | 16 | return IsAspNetNativeController(typeInfo); 17 | } 18 | 19 | private bool IsAspNetNativeController(TypeInfo typeInfo) 20 | { 21 | return base.IsController(typeInfo); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/NClient/NClient.AspNetCore/Filters/HttpResponseExceptionFilter.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.Filters; 3 | using NClient.AspNetCore.Exceptions; 4 | 5 | namespace NClient.AspNetCore.Filters 6 | { 7 | internal class HttpResponseExceptionFilter : IActionFilter, IOrderedFilter 8 | { 9 | public int Order => int.MaxValue; 10 | 11 | public void OnActionExecuting(ActionExecutingContext context) 12 | { 13 | } 14 | 15 | public void OnActionExecuted(ActionExecutedContext context) 16 | { 17 | if (context.Exception is HttpResponseException exception) 18 | { 19 | context.Result = new ObjectResult(exception.Value) 20 | { 21 | StatusCode = (int) exception.Status 22 | }; 23 | context.ExceptionHandled = true; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/NClient/NClient.AspNetCore/NClientAssemblyNames.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.AspNetCore 2 | { 3 | internal static class NClientAssemblyNames 4 | { 5 | public static string NClientDynamicControllerProxies { get; } = "NClient.Dynamic.VirtualControllers"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NClient/NClient.AspNetProxy.Standalone/Controllers/VirtualControllerInterceptor.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Castle.DynamicProxy; 3 | 4 | namespace NClient.AspNetProxy.Controllers 5 | { 6 | internal class VirtualControllerInterceptor : IInterceptor 7 | { 8 | private readonly object _target; 9 | 10 | public VirtualControllerInterceptor(object target) 11 | { 12 | _target = target; 13 | } 14 | 15 | public void Intercept(IInvocation invocation) 16 | { 17 | var methodName = invocation.Method.Name; 18 | var methodParamTypes = invocation.Method.GetParameters().Select(x => x.ParameterType).ToArray(); 19 | 20 | invocation.ReturnValue = _target.GetType() 21 | .GetMethod(methodName, methodParamTypes)! 22 | .Invoke(_target, invocation.Arguments); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/NClient/NClient.AspNetProxy.Standalone/Exceptions/Factories/OuterAspNetExceptionFactory.cs: -------------------------------------------------------------------------------- 1 | using NClient.Core.Exceptions; 2 | 3 | namespace NClient.AspNetProxy.Exceptions.Factories 4 | { 5 | internal static class OuterAspNetExceptionFactory 6 | { 7 | public static NClientException ControllerCanHaveOnlyOneInterface(string controllerName) => 8 | new($"Controller '{controllerName}' can have only one NClient interface."); 9 | 10 | public static NClientException ControllerInterfaceNotFound(string controllerName) => 11 | new($"NClient interface for controller '{controllerName}' not found."); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.AspNetProxy.Standalone/NClientAssemblyNames.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.AspNetProxy 2 | { 3 | public class NClientAssemblyNames 4 | { 5 | public static string NClientDynamicControllerProxies { get; } = "NClient.Dynamic.VirtualControllers"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/NClient/NClient.Common/Helpers/Converters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Common.Helpers 4 | { 5 | internal static class Converters 6 | { 7 | public static string GetString(byte[] source) 8 | { 9 | var chars = new char[source.Length]; 10 | Buffer.BlockCopy(source, 0, chars, 0, source.Length); 11 | return new string(chars); 12 | } 13 | 14 | public static byte[] GetBytes(string source) 15 | { 16 | var result = new byte[source.Length]; 17 | Buffer.BlockCopy(source.ToCharArray(), 0, result, 0, result.Length); 18 | return result; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/NClient/NClient.Common/Helpers/EnumExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace NClient.Common.Helpers 5 | { 6 | internal static class EnumExtensions 7 | { 8 | public static string GetDescription(this Enum value) 9 | { 10 | var resultDescription = string.Empty; 11 | var type = value.GetType(); 12 | var name = Enum.GetName(type, value); 13 | Ensure.IsNotNull(name, nameof(name)); 14 | Ensure.IsNotNullOrEmpty(name, nameof(name)); 15 | var field = type.GetField(name); 16 | Ensure.IsNotNull(name, nameof(field)); 17 | if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attr) 18 | resultDescription = attr.Description; 19 | Ensure.IsNotNullOrEmpty(resultDescription, nameof(resultDescription)); 20 | return resultDescription; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/NClient/NClient.Common/NClient.Common.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0;netstandard2.1 5 | 9.0 6 | enable 7 | true 8 | true 9 | false 10 | Debug;Release 11 | AnyCPU 12 | $(SolutionDir)/bin/src/$(Configuration)/$(AssemblyName) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/AspNetRouting/RoutePatternLiteralPart.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace NClient.Core.AspNetRouting 4 | { 5 | /// 6 | /// Resprents a literal text part of a route pattern. Instances of 7 | /// are immutable. 8 | /// 9 | internal sealed class RoutePatternLiteralPart : RoutePatternPart 10 | { 11 | internal RoutePatternLiteralPart(string content) 12 | : base(RoutePatternPartKind.Literal) 13 | { 14 | Debug.Assert(!string.IsNullOrEmpty(content)); 15 | Content = content; 16 | } 17 | 18 | /// 19 | /// Gets the text content. 20 | /// 21 | public string Content { get; } 22 | 23 | internal override string DebuggerToString() 24 | { 25 | return Content; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/AspNetRouting/RoutePatternParameterKind.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Core.AspNetRouting 2 | { 3 | /// 4 | /// Defines the kinds of instances. 5 | /// 6 | internal enum RoutePatternParameterKind 7 | { 8 | /// 9 | /// The of a standard parameter 10 | /// without optional or catch all behavior. 11 | /// 12 | Standard, 13 | 14 | /// 15 | /// The of an optional parameter. 16 | /// 17 | Optional, 18 | 19 | /// 20 | /// The of a catch-all parameter. 21 | /// 22 | CatchAll 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/AspNetRouting/RoutePatternPartKind.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Core.AspNetRouting 2 | { 3 | /// 4 | /// Defines the kinds of instances. 5 | /// 6 | internal enum RoutePatternPartKind 7 | { 8 | /// 9 | /// The of a . 10 | /// 11 | Literal, 12 | 13 | /// 14 | /// The of a . 15 | /// 16 | Parameter, 17 | 18 | /// 19 | /// The of a . 20 | /// 21 | Separator 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/AspNetRouting/TemplateParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Core.AspNetRouting 4 | { 5 | internal static class TemplateParser 6 | { 7 | public static RouteTemplate Parse(string routeTemplate) 8 | { 9 | if (routeTemplate == null) 10 | { 11 | throw new ArgumentNullException(routeTemplate); 12 | } 13 | 14 | try 15 | { 16 | var inner = RoutePatternFactory.Parse(routeTemplate); 17 | return new RouteTemplate(inner); 18 | } 19 | catch (RoutePatternException ex) 20 | { 21 | // Preserving the existing behavior of this API even though the logic moved. 22 | throw new ArgumentException(ex.Message, nameof(routeTemplate), ex); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Extensions/RequestTypeExtensions.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Transport; 2 | 3 | namespace NClient.Core.Extensions 4 | { 5 | internal static class RequestTypeExtensions 6 | { 7 | public static bool IsIdempotent(this RequestType requestType) 8 | { 9 | return requestType switch 10 | { 11 | RequestType.Create => false, 12 | _ => true 13 | }; 14 | } 15 | 16 | public static bool IsSafe(this RequestType requestType) 17 | { 18 | return requestType switch 19 | { 20 | RequestType.Info => true, 21 | RequestType.Check => true, 22 | RequestType.Read => true, 23 | _ => false 24 | }; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NClient.Core.Helpers 5 | { 6 | internal static class EnumerableExtensions 7 | { 8 | public static IEnumerable DistinctBy(this IEnumerable source, Func keySelector) 9 | { 10 | HashSet seenKeys = new(); 11 | foreach (var element in source) 12 | { 13 | if (seenKeys.Add(keySelector(element))) 14 | yield return element; 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/EqualityComparers/MethodInfoEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace NClient.Core.Helpers.EqualityComparers 4 | { 5 | internal class MethodInfoEqualityComparer : OverridingMethodInfoEqualityComparer 6 | { 7 | public override bool Equals(MethodInfo left, MethodInfo right) 8 | { 9 | if (ReferenceEquals(left, right)) 10 | return true; 11 | if (left.GetType() != right.GetType()) 12 | return false; 13 | 14 | return base.Equals(left, right) && left.ReturnType == right.ReturnType; 15 | } 16 | 17 | public override int GetHashCode(MethodInfo obj) 18 | { 19 | unchecked 20 | { 21 | var hashCode = base.GetHashCode(obj); 22 | hashCode = (hashCode * 397) ^ obj.ReturnType.GetHashCode(); 23 | return hashCode; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/EqualityComparers/ReferenceAttributeEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NClient.Core.Helpers.EqualityComparers 5 | { 6 | internal class ReferenceAttributeEqualityComparer : IEqualityComparer 7 | { 8 | public bool Equals(Attribute left, Attribute right) 9 | { 10 | return ReferenceEquals(left, right); 11 | } 12 | public int GetHashCode(Attribute attribute) 13 | { 14 | return attribute.GetHashCode(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/GuidProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace NClient.Core.Helpers 5 | { 6 | internal interface IGuidProvider 7 | { 8 | Guid Create(); 9 | } 10 | 11 | [SuppressMessage("ReSharper", "GuidNew")] 12 | internal class GuidProvider : IGuidProvider 13 | { 14 | public Guid Create() 15 | { 16 | return Guid.NewGuid(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/ObjectMemberManagers/Factories/IObjectMemberManagerExceptionFactory.cs: -------------------------------------------------------------------------------- 1 | using NClient.Exceptions; 2 | 3 | namespace NClient.Core.Helpers.ObjectMemberManagers.Factories 4 | { 5 | internal interface IObjectMemberManagerExceptionFactory 6 | { 7 | NClientException MemberNameConflict(string memberName, string objectName); 8 | NClientException MemberNotFound(string memberName, string objectName); 9 | NClientException MemberValueOfObjectInRouteIsNull(string memberName, string objectName); 10 | NClientException RoutePropertyConvertError(string memberName, string propertyTypeName, string? actualValue); 11 | NClientException LimitNestingOfObjects(int limit, string processingObjectName); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/ObjectMemberManagers/MemberNameSelectors/DefaultMemberNameSelector.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace NClient.Core.Helpers.ObjectMemberManagers.MemberNameSelectors 4 | { 5 | internal class DefaultMemberNameSelector : IMemberNameSelector 6 | { 7 | public string GetName(MemberInfo memberInfo) 8 | { 9 | return memberInfo.Name; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/ObjectMemberManagers/MemberNameSelectors/IMemberNameSelector.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace NClient.Core.Helpers.ObjectMemberManagers.MemberNameSelectors 4 | { 5 | internal interface IMemberNameSelector 6 | { 7 | string GetName(MemberInfo memberInfo); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/ObjectToKeyValueConverters/Factories/IObjectToKeyValueConverterExceptionFactory.cs: -------------------------------------------------------------------------------- 1 | using NClient.Exceptions; 2 | 3 | namespace NClient.Core.Helpers.ObjectToKeyValueConverters.Factories 4 | { 5 | internal interface IObjectToKeyValueConverterExceptionFactory 6 | { 7 | ClientValidationException DictionaryWithComplexTypeOfKeyNotSupported(); 8 | ClientValidationException DictionaryWithComplexTypeOfValueNotSupported(); 9 | ClientValidationException ArrayWithComplexTypeNotSupported(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/ObjectToKeyValueConverters/PropertyKeyValue.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Core.Helpers.ObjectToKeyValueConverters 2 | { 3 | internal class PropertyKeyValue 4 | { 5 | public string Key { get; } 6 | public object? Value { get; } 7 | 8 | public PropertyKeyValue(string key, object? value) 9 | { 10 | Key = key; 11 | Value = value; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Helpers/PathHelper.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Core.Helpers 2 | { 3 | internal static class PathHelper 4 | { 5 | public static string Combine(string left, string right) 6 | { 7 | return $"{left.TrimStart('/').TrimEnd('/')}/{right.TrimStart('/').TrimEnd('/')}"; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Mappers/AttributeMapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Core.Mappers 4 | { 5 | internal interface IAttributeMapper 6 | { 7 | Attribute? TryMap(Attribute attribute); 8 | } 9 | 10 | internal class AttributeMapper : IAttributeMapper 11 | { 12 | public Attribute TryMap(Attribute attribute) 13 | { 14 | return attribute switch 15 | { 16 | { } => attribute, 17 | _ => throw new ArgumentNullException(nameof(attribute)) 18 | }; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Proxy/IProxyGeneratorProvider.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | 3 | namespace NClient.Core.Proxy 4 | { 5 | internal interface IProxyGeneratorProvider 6 | { 7 | IProxyGenerator Value { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/NClient/NClient.Core/Proxy/SingletonProxyGeneratorProvider.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | 3 | namespace NClient.Core.Proxy 4 | { 5 | internal class SingletonProxyGeneratorProvider : IProxyGeneratorProvider 6 | { 7 | private static readonly IProxyGenerator ProxyGenerator = new ProxyGenerator(); 8 | 9 | public IProxyGenerator Value => ProxyGenerator; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/NClient/NClient.InterfaceProxy.Standalone/NClientControllerStandaloneProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.Abstractions.HttpClients; 3 | 4 | namespace NClient.AspNetProxy 5 | { 6 | [Obsolete("The right way is to add NClient controllers (see AddNClientControllers) and use NClientStandaloneProvider.")] 7 | public static class NClientControllerStandaloneProvider 8 | { 9 | public static INClientControllerBuilder Use( 10 | string host, IHttpClientProvider httpClientProvider) 11 | where TInterface : class 12 | where TController : TInterface 13 | { 14 | return new NClientControllerBuilder().Use(host, httpClientProvider); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.InterfaceProxy.Standalone/NClientStandaloneProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Abstractions.HttpClients; 2 | 3 | namespace NClient.InterfaceProxy 4 | { 5 | public static class NClientStandaloneProvider 6 | { 7 | public static INClientBuilder Use(string host, IHttpClientProvider httpClientProvider) where T : class 8 | { 9 | return new NClientBuilder().Use(host, httpClientProvider); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/NClient/NClient.InterfaceProxy/NClientProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.HttpClient.RestSharp; 2 | using RestSharp.Authenticators; 3 | 4 | namespace NClient.InterfaceProxy 5 | { 6 | public static class NClientProvider 7 | { 8 | public static INClientBuilder Use(string host) where T : class 9 | { 10 | return new NClientBuilder().Use(host, new RestSharpHttpClientProvider()); 11 | } 12 | 13 | public static INClientBuilder Use(string host, IAuthenticator authenticator) where T : class 14 | { 15 | return new NClientBuilder().Use(host, new RestSharpHttpClientProvider(authenticator)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Client/Authorization/Authorization.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using NClient.Providers.Authorization; 4 | 5 | namespace NClient.Standalone.Client.Authorization 6 | { 7 | internal class Authorization : IAuthorization 8 | { 9 | private readonly IAccessTokens? _accessTokens; 10 | 11 | public Authorization() 12 | { 13 | } 14 | 15 | public Authorization(IAccessTokens accessTokens) 16 | { 17 | _accessTokens = accessTokens; 18 | } 19 | 20 | public Task TryGetAccessTokensAsync(CancellationToken cancellationToken) 21 | { 22 | return Task.FromResult(_accessTokens); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Client/Authorization/AuthorizationProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Authorization; 3 | 4 | namespace NClient.Standalone.Client.Authorization 5 | { 6 | internal class AuthorizationProvider : IAuthorizationProvider 7 | { 8 | private readonly IAccessTokens? _tokens; 9 | 10 | public AuthorizationProvider(IAccessTokens? tokens) 11 | { 12 | _tokens = tokens; 13 | } 14 | 15 | public IAuthorization Create(IToolset toolset) 16 | { 17 | if (_tokens is not null) 18 | return new Authorization(_tokens); 19 | 20 | return new Authorization(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Client/Authorization/CompositeAuthorizationProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using NClient.Providers; 4 | using NClient.Providers.Authorization; 5 | 6 | namespace NClient.Standalone.Client.Authorization 7 | { 8 | internal class CompositeAuthorizationProvider : IAuthorizationProvider 9 | { 10 | private readonly IReadOnlyCollection _authorizationProviders; 11 | 12 | public CompositeAuthorizationProvider(IReadOnlyCollection authorizationProviders) 13 | { 14 | _authorizationProviders = authorizationProviders; 15 | } 16 | 17 | public IAuthorization Create(IToolset toolset) 18 | { 19 | return new CompositeAuthorization(_authorizationProviders 20 | .Select(x => x.Create(toolset)) 21 | .ToArray()); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Client/Handling/ClientHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Handling; 3 | 4 | namespace NClient.Standalone.Client.Handling 5 | { 6 | internal class ClientHandlerProvider : IClientHandlerProvider 7 | { 8 | private readonly IClientHandler _clientHandler; 9 | 10 | public ClientHandlerProvider(IClientHandler clientHandler) 11 | { 12 | _clientHandler = clientHandler; 13 | } 14 | 15 | public IClientHandler Create(IToolset toolset) 16 | { 17 | return _clientHandler; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Client/Logging/CompositeDisposable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NClient.Standalone.Client.Logging 5 | { 6 | internal class CompositeDisposable : IDisposable 7 | { 8 | private readonly IEnumerable _disposables; 9 | 10 | public CompositeDisposable(IEnumerable disposables) 11 | { 12 | _disposables = disposables; 13 | } 14 | 15 | public void Dispose() 16 | { 17 | foreach (var disposable in _disposables) 18 | { 19 | disposable.Dispose(); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Client/Mapping/ResponseMapperProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Mapping; 3 | 4 | namespace NClient.Standalone.Client.Mapping 5 | { 6 | internal class ResponseMapperProvider : IResponseMapperProvider 7 | { 8 | private readonly IResponseMapper _responseMapper; 9 | 10 | public ResponseMapperProvider(IResponseMapper responseMapper) 11 | { 12 | _responseMapper = responseMapper; 13 | } 14 | 15 | public IResponseMapper Create(IToolset toolset) 16 | { 17 | return _responseMapper; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Client/Resilience/ResiliencePolicyProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Resilience; 3 | 4 | namespace NClient.Standalone.Client.Resilience 5 | { 6 | internal class ResiliencePolicyProvider : IResiliencePolicyProvider 7 | { 8 | private readonly IResiliencePolicy _resiliencePolicy; 9 | 10 | public ResiliencePolicyProvider(IResiliencePolicy resiliencePolicy) 11 | { 12 | _resiliencePolicy = resiliencePolicy; 13 | } 14 | 15 | public IResiliencePolicy Create(IToolset toolset) 16 | { 17 | return _resiliencePolicy; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Building/Configuration/Handling/NClientHandlingSelector.cs: -------------------------------------------------------------------------------- 1 | using NClient.Standalone.ClientProxy.Building.Context; 2 | 3 | namespace NClient.Standalone.ClientProxy.Building.Configuration.Handling 4 | { 5 | internal class NClientHandlingSelector : INClientHandlingSelector 6 | { 7 | private readonly BuilderContextModifier _builderContextModifier; 8 | 9 | public NClientHandlingSelector(BuilderContextModifier builderContextModifier) 10 | { 11 | _builderContextModifier = builderContextModifier; 12 | } 13 | 14 | public INClientTransportHandlingSetter ForTransport() 15 | { 16 | return new NClientTransportHandlingSetter(_builderContextModifier); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Building/Configuration/Validation/NClientResponseValidationSelector.cs: -------------------------------------------------------------------------------- 1 | using NClient.Standalone.ClientProxy.Building.Context; 2 | 3 | namespace NClient.Standalone.ClientProxy.Building.Configuration.Validation 4 | { 5 | internal class NClientResponseValidationSelector : INClientResponseValidationSelector 6 | { 7 | private readonly BuilderContextModifier _builderContextModifier; 8 | 9 | public NClientResponseValidationSelector(BuilderContextModifier builderContextModifier) 10 | { 11 | _builderContextModifier = builderContextModifier; 12 | } 13 | 14 | public INClientTransportResponseValidationSetter ForTransport() 15 | { 16 | return new NClientTransportResponseValidationSetter(_builderContextModifier); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Building/Factory/NClientFactoryApiBuilder.cs: -------------------------------------------------------------------------------- 1 | using NClient.Common.Helpers; 2 | using NClient.Providers.Api; 3 | 4 | namespace NClient.Standalone.ClientProxy.Building.Factory 5 | { 6 | internal class NClientFactoryApiBuilder : INClientFactoryApiBuilder 7 | { 8 | private readonly string _factoryName; 9 | 10 | public NClientFactoryApiBuilder(string factoryName) 11 | { 12 | _factoryName = factoryName; 13 | } 14 | 15 | public INClientFactoryTransportBuilder UsingCustomApi(IRequestBuilderProvider requestBuilderProvider) 16 | { 17 | Ensure.IsNotNull(requestBuilderProvider, nameof(requestBuilderProvider)); 18 | 19 | return new NClientFactoryTransportBuilder(_factoryName, requestBuilderProvider); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Building/Models/ResiliencePolicyPredicate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.Invocation; 3 | using NClient.Providers.Resilience; 4 | using NClient.Providers.Transport; 5 | 6 | namespace NClient.Standalone.ClientProxy.Building.Models 7 | { 8 | internal class ResiliencePolicyPredicate 9 | { 10 | public IResiliencePolicyProvider Provider { get; } 11 | public Func Predicate { get; } 12 | 13 | public ResiliencePolicyPredicate(IResiliencePolicyProvider provider, Func predicate) 14 | { 15 | Provider = provider; 16 | Predicate = predicate; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Building/NClientApiBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.Common.Helpers; 3 | using NClient.Providers.Api; 4 | 5 | namespace NClient.Standalone.ClientProxy.Building 6 | { 7 | internal class NClientApiBuilder : INClientApiBuilder 8 | where TClient : class 9 | { 10 | private readonly Uri _host; 11 | 12 | public NClientApiBuilder(Uri host) 13 | { 14 | _host = host; 15 | } 16 | 17 | public INClientTransportBuilder UsingCustomApi(IRequestBuilderProvider requestBuilderProvider) 18 | { 19 | Ensure.IsNotNull(requestBuilderProvider, nameof(requestBuilderProvider)); 20 | 21 | return new NClientTransportBuilder(_host, requestBuilderProvider); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Generation/Interceptors/KeepDataInterceptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Castle.DynamicProxy; 3 | 4 | namespace NClient.Standalone.ClientProxy.Generation.Interceptors 5 | { 6 | internal class KeepDataInterceptor : IInterceptor 7 | { 8 | public IInvocation? Invocation { get; private set; } 9 | 10 | public void Intercept(IInvocation invocation) 11 | { 12 | Invocation = invocation; 13 | var concreteMethod = invocation.GetConcreteMethod(); 14 | 15 | if (concreteMethod.ReturnType.IsValueType && concreteMethod.ReturnType != typeof(void)) 16 | invocation.ReturnValue = Activator.CreateInstance(concreteMethod.ReturnType); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Generation/Invocation/ClientMethodInvocation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using NClient.Invocation; 4 | using NClient.Providers.Resilience; 5 | 6 | namespace NClient.Standalone.ClientProxy.Generation.Invocation 7 | { 8 | internal class ClientMethodInvocation : MethodInvocation 9 | { 10 | public IResiliencePolicyProvider? ResiliencePolicyProvider { get; } 11 | public CancellationToken? CancellationToken { get; } 12 | 13 | public ClientMethodInvocation( 14 | IMethod method, IEnumerable arguments, 15 | IResiliencePolicyProvider? resiliencePolicyProvider, CancellationToken? cancellationToken) 16 | : base(method, arguments) 17 | { 18 | ResiliencePolicyProvider = resiliencePolicyProvider; 19 | CancellationToken = cancellationToken; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Api/StubRequestBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using NClient.Providers.Api; 5 | using NClient.Providers.Authorization; 6 | using NClient.Providers.Transport; 7 | 8 | namespace NClient.Standalone.ClientProxy.Validation.Api 9 | { 10 | internal class StubRequestBuilder : IRequestBuilder 11 | { 12 | public Task BuildAsync(Guid requestId, Uri host, IAuthorization authorization, IMethodInvocation methodInvocation, CancellationToken cancellationToken) 13 | { 14 | return Task.FromResult(new Request(requestId, host, RequestType.Custom)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Api/StubRequestBuilderProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Api; 3 | 4 | namespace NClient.Standalone.ClientProxy.Validation.Api 5 | { 6 | internal class StubRequestBuilderProvider : IRequestBuilderProvider 7 | { 8 | public IRequestBuilder Create(IToolset toolset) 9 | { 10 | return new StubRequestBuilder(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Authorization/StubAuthorization.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using NClient.Providers.Authorization; 4 | 5 | namespace NClient.Standalone.ClientProxy.Validation.Authorization 6 | { 7 | internal class StubAuthorization : IAuthorization 8 | { 9 | public Task TryGetAccessTokensAsync(CancellationToken cancellationToken) 10 | { 11 | return Task.FromResult(null); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Authorization/StubAuthorizationProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Authorization; 3 | 4 | namespace NClient.Standalone.ClientProxy.Validation.Authorization 5 | { 6 | internal class StubAuthorizationProvider : IAuthorizationProvider 7 | { 8 | public IAuthorization Create(IToolset toolset) 9 | { 10 | return new StubAuthorization(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Handling/StubClientHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using NClient.Providers.Handling; 4 | 5 | namespace NClient.Standalone.ClientProxy.Validation.Handling 6 | { 7 | internal class StubClientHandler : IClientHandler 8 | { 9 | public Task HandleRequestAsync(TRequest request, CancellationToken cancellationToken) 10 | { 11 | return Task.FromResult(request); 12 | } 13 | 14 | public Task HandleResponseAsync(TResponse response, CancellationToken cancellationToken) 15 | { 16 | return Task.FromResult(response); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Handling/StubClientHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Handling; 3 | 4 | namespace NClient.Standalone.ClientProxy.Validation.Handling 5 | { 6 | internal class StubClientHandlerProvider : IClientHandlerProvider 7 | { 8 | public IClientHandler Create(IToolset toolset) 9 | { 10 | return new StubClientHandler(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Resilience/StubResiliencePolicy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using NClient.Providers.Resilience; 5 | using NClient.Providers.Transport; 6 | 7 | namespace NClient.Standalone.ClientProxy.Validation.Resilience 8 | { 9 | internal class StubResiliencePolicy : IResiliencePolicy 10 | { 11 | public async Task> ExecuteAsync( 12 | Func>> action, CancellationToken cancellationToken) 13 | { 14 | return await action.Invoke(cancellationToken).ConfigureAwait(false); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Resilience/StubResiliencePolicyProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Resilience; 3 | 4 | namespace NClient.Standalone.ClientProxy.Validation.Resilience 5 | { 6 | internal class StubResiliencePolicyProvider : IResiliencePolicyProvider 7 | { 8 | public IResiliencePolicy Create(IToolset toolset) 9 | { 10 | return new StubResiliencePolicy(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Serialization/StubSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.Providers.Serialization; 3 | 4 | namespace NClient.Standalone.ClientProxy.Validation.Serialization 5 | { 6 | internal class StubSerializer : ISerializer 7 | { 8 | public string ContentType { get; } = "application/json"; 9 | 10 | public object? Deserialize(string source, Type returnType) 11 | { 12 | return null; 13 | } 14 | 15 | public string Serialize(T? value) 16 | { 17 | return ""; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Serialization/StubSerializerProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using NClient.Providers.Serialization; 3 | 4 | namespace NClient.Standalone.ClientProxy.Validation.Serialization 5 | { 6 | internal class StubSerializerProvider : ISerializerProvider 7 | { 8 | public ISerializer Create(ILogger logger) 9 | { 10 | return new StubSerializer(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Transport/StubResponseBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using NClient.Providers.Transport; 4 | 5 | namespace NClient.Standalone.ClientProxy.Validation.Transport 6 | { 7 | internal class StubResponseBuilder : IResponseBuilder 8 | { 9 | public Task BuildAsync(IRequest request, 10 | IResponseContext responseContext, 11 | bool allocateMemoryForContent, 12 | CancellationToken cancellationToken) 13 | { 14 | return Task.FromResult(responseContext.Response); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Transport/StubResponseBuilderProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Transport; 3 | 4 | namespace NClient.Standalone.ClientProxy.Validation.Transport 5 | { 6 | internal class StubResponseBuilderProvider : IResponseBuilderProvider 7 | { 8 | public IResponseBuilder Create(IToolset toolset) 9 | { 10 | return new StubResponseBuilder(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Transport/StubTransportBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using NClient.Providers.Transport; 5 | 6 | namespace NClient.Standalone.ClientProxy.Validation.Transport 7 | { 8 | internal class StubTransportBuilder : ITransport 9 | { 10 | public TimeSpan Timeout => System.Threading.Timeout.InfiniteTimeSpan; 11 | 12 | public Task ExecuteAsync(IRequest transportRequest, CancellationToken cancellationToken) 13 | { 14 | var response = new Response(transportRequest) { StatusCode = 200 }; 15 | return Task.FromResult(response); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Transport/StubTransportProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Transport; 3 | 4 | namespace NClient.Standalone.ClientProxy.Validation.Transport 5 | { 6 | internal class StubTransportProvider : ITransportProvider 7 | { 8 | public ITransport Create(IToolset toolset) 9 | { 10 | return new StubTransportBuilder(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Transport/StubTransportRequestBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using NClient.Providers.Transport; 4 | 5 | namespace NClient.Standalone.ClientProxy.Validation.Transport 6 | { 7 | internal class StubTransportRequestBuilder : ITransportRequestBuilder 8 | { 9 | public Task BuildAsync(IRequest request, CancellationToken cancellationToken) 10 | { 11 | return Task.FromResult(request); 12 | } 13 | public Task BuildResponseAsync(IResponseContext responseContext, 14 | CancellationToken cancellationToken) 15 | { 16 | return Task.FromResult(responseContext.Response); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Transport/StubTransportRequestBuilderProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Transport; 3 | using NClient.Providers.Transport.Common; 4 | 5 | namespace NClient.Standalone.ClientProxy.Validation.Transport 6 | { 7 | internal class StubTransportRequestBuilderProvider : ITransportRequestBuilderProvider 8 | { 9 | public ITransportRequestBuilder Create(IToolset toolset) 10 | { 11 | return new StubTransportRequestBuilder(); 12 | } 13 | 14 | public ITransportRequestBuilder Create(IToolset toolset, IPipelineCanceller pipelineCanceller) 15 | { 16 | pipelineCanceller.Cancel(); 17 | return new StubTransportRequestBuilder(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Validation/StubResponseValidator.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Providers.Transport; 3 | using NClient.Providers.Validation; 4 | 5 | namespace NClient.Standalone.ClientProxy.Validation.Validation 6 | { 7 | internal class StubResponseValidator : IResponseValidator 8 | { 9 | public bool IsSuccess(IResponseContext responseContext) 10 | { 11 | return true; 12 | } 13 | 14 | public Task OnFailureAsync(IResponseContext responseContext) 15 | { 16 | return Task.CompletedTask; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/ClientProxy/Validation/Validation/StubResponseValidatorProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers; 2 | using NClient.Providers.Validation; 3 | 4 | namespace NClient.Standalone.ClientProxy.Validation.Validation 5 | { 6 | internal class StubResponseValidatorProvider : IResponseValidatorProvider 7 | { 8 | public IResponseValidator Create(IToolset toolset) 9 | { 10 | return new StubResponseValidator(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Exceptions/ClientBuildException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Exceptions 5 | { 6 | /// Represents exceptions thrown during client creation. 7 | public class ClientBuildException : NClientException 8 | { 9 | public ClientBuildException(string message) : base(message) 10 | { 11 | } 12 | 13 | public ClientBuildException(string message, Exception innerException) : base(message, innerException) 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Exceptions/Factories/ClientRequestExceptionFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using NClient.Exceptions; 4 | 5 | namespace NClient.Standalone.Exceptions.Factories 6 | { 7 | internal interface IClientRequestExceptionFactory 8 | { 9 | ClientRequestException WrapException(Type interfaceType, MethodInfo methodInfo, Exception exception); 10 | } 11 | 12 | internal class ClientRequestExceptionFactory : IClientRequestExceptionFactory 13 | { 14 | public ClientRequestException WrapException(Type interfaceType, MethodInfo methodInfo, Exception exception) => 15 | new(exception.Message, interfaceType, methodInfo, exception); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Extensions/Mapping/Results/UseResultsExtensions.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Mapping.Results; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient 5 | { 6 | public static class UseResultsExtensions 7 | { 8 | /// Sets the mapper that converts NClient requests and responses into NClient results with deserialized data. 9 | public static INClientResponseMappingSelector UseResults( 10 | this INClientResponseMappingSetter responseMappingSetter) 11 | { 12 | return responseMappingSetter.Use(new ResponseToResultMapperProvider()); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/NClientBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NClient.Common.Helpers; 3 | using NClient.Standalone.ClientProxy.Building; 4 | 5 | // ReSharper disable once CheckNamespace 6 | namespace NClient 7 | { 8 | internal class NClientBuilder : INClientBuilder 9 | { 10 | public INClientApiBuilder For(string host) where TClient : class 11 | { 12 | Ensure.IsNotNull(host, nameof(host)); 13 | return For(new Uri(host)); 14 | } 15 | 16 | public INClientApiBuilder For(Uri host) where TClient : class 17 | { 18 | Ensure.IsNotNull(host, nameof(host)); 19 | return new NClientApiBuilder(host); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/NClientFactoryBuilder.cs: -------------------------------------------------------------------------------- 1 | using NClient.Common.Helpers; 2 | using NClient.Standalone.ClientProxy.Building.Factory; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient 6 | { 7 | /// The builder used to create the client factory with custom providers. 8 | public class NClientFactoryBuilder : INClientFactoryBuilder 9 | { 10 | /// Sets factory name. The factory name does not affect the functionality, it may be needed to identify the factory. 11 | /// The factory name. 12 | public INClientFactoryApiBuilder For(string factoryName) 13 | { 14 | Ensure.IsNotNullOrEmpty(factoryName, nameof(factoryName)); 15 | return new NClientFactoryApiBuilder(factoryName); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Options/NClientBuilderOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient 6 | { 7 | /// An options class for configuring a client. 8 | public class NClientBuilderOptions where TClient : class 9 | { 10 | /// Gets a list of operations used to configure a client. 11 | public IList, INClientOptionalBuilder>> BuilderActions { get; } 12 | = new List, INClientOptionalBuilder>>(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Options/NClientFactoryBuilderOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace NClient 6 | { 7 | /// An options class for configuring a client factory. 8 | public class NClientFactoryBuilderOptions 9 | { 10 | /// Gets a list of operations used to configure a client factory. 11 | public IList, INClientFactoryOptionalBuilder>> BuilderActions { get; } 12 | = new List, INClientFactoryOptionalBuilder>>(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Providers/Mapping/ResponseToResult/ResponseToResultMapperProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Transport; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Providers.Mapping.Results 5 | { 6 | public class ResponseToResultMapperProvider : IResponseMapperProvider 7 | { 8 | public IResponseMapper Create(IToolset toolset) 9 | { 10 | return new ResponseToResultMapper(toolset); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Providers/Mapping/ResponseToResult/Result.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient.Providers.Mapping.Results 4 | { 5 | public interface IResult 6 | { 7 | public TValue Value { get; } 8 | public TError Error { get; } 9 | } 10 | 11 | public class Result : IResult 12 | { 13 | public TValue Value { get; } 14 | public TError Error { get; } 15 | 16 | public Result(TValue value, TError error) 17 | { 18 | Value = value; 19 | Error = error; 20 | } 21 | 22 | public void Deconstruct(out TValue? value, out TError? error) 23 | { 24 | value = Value; 25 | error = Error; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Providers/Mapping/ResponseToStream/ResponseToStreamMapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using NClient.Providers.Transport; 6 | 7 | // ReSharper disable once CheckNamespace 8 | namespace NClient.Providers.Mapping 9 | { 10 | public class ResponseToStreamMapper : IResponseMapper 11 | { 12 | public bool CanMap(Type resultType, IResponseContext responseContext) 13 | { 14 | return resultType == typeof(Stream); 15 | } 16 | 17 | public Task MapAsync(Type resultType, IResponseContext responseContext, CancellationToken cancellationToken) 18 | { 19 | return Task.FromResult(responseContext.Response.Content.Stream); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/NClient/NClient.Standalone/Providers/Mapping/ResponseToStream/ResponseToStreamMapperProvider.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Transport; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient.Providers.Mapping 5 | { 6 | public class ResponseToStreamMapperProvider : IResponseMapperProvider 7 | { 8 | public IResponseMapper Create(IToolset toolset) 9 | { 10 | return new ResponseToStreamMapper(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/NClient/NClient/Extensions/Streams/UseStreamsExtensions.cs: -------------------------------------------------------------------------------- 1 | using NClient.Providers.Mapping; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient 5 | { 6 | public static class UseStreamsExtensions 7 | { 8 | public static INClientResponseMappingSelector UseStreams( 9 | this INClientResponseMappingSetter responseMappingSetter) 10 | { 11 | return responseMappingSetter.Use(new ResponseToStreamMapperProvider()); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NClient/NClient/Extensions/Validation/UseResponseValidationExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | 3 | // ReSharper disable once CheckNamespace 4 | namespace NClient 5 | { 6 | public static class UseResponseValidationExtensions 7 | { 8 | /// Sets default response validation of the contents received from HTTP transport. 9 | public static INClientResponseValidationSelector Use( 10 | this INClientTransportResponseValidationSetter transportResponseValidationSetter) 11 | { 12 | return transportResponseValidationSetter.UseSystemNetHttpResponseValidation(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/NClient/NClient/Gallery/ClientFactoryGallery.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | 3 | namespace NClient 4 | { 5 | /// The container of builder sets for creating pre-configured client factories. 6 | public interface IClientFactoryGallery 7 | { 8 | /// Gets the client builder factory for a REST-like web API with JSON-formatted data. 9 | IRestNClientFactoryBuilder GetRest(); 10 | 11 | /// Gets the builder used to create the client factory with custom providers. 12 | INClientFactoryBuilder GetCustom(); 13 | } 14 | 15 | public class ClientFactoryGallery : IClientFactoryGallery 16 | { 17 | public IRestNClientFactoryBuilder GetRest() => new RestNClientFactoryBuilder(); 18 | public INClientFactoryBuilder GetCustom() => new NClientFactoryBuilder(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/NClient.Api/NClient.Api.Tests/BasicClientUseCases/SerializerTest.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading.Tasks; 3 | using FluentAssertions; 4 | using NClient.Testing.Common.Apis; 5 | using NClient.Testing.Common.Clients; 6 | using NUnit.Framework; 7 | 8 | namespace NClient.Api.Tests.BasicClientUseCases 9 | { 10 | [Parallelizable] 11 | public class SerializerTest 12 | { 13 | [Test] 14 | public async Task NClientBuilder_WithNewtonsoft_NotThrow() 15 | { 16 | const int id = 1; 17 | using var api = BasicApiMockFactory.MockGetMethod(id); 18 | var client = NClientGallery.Clients.GetRest().For(host: api.Urls.First()) 19 | .WithNewtonsoftJsonSerialization() 20 | .Build(); 21 | 22 | var response = await client.GetAsync(id); 23 | 24 | response.Should().Be(id); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/NClient.Api/NClient.Api.Tests/Stubs/CustomHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using NClient.Providers.Handling; 6 | 7 | namespace NClient.Api.Tests.Stubs 8 | { 9 | public class CustomHandler : IClientHandler 10 | { 11 | public Task HandleRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken) 12 | { 13 | Console.WriteLine("Request is starting..."); 14 | return Task.FromResult(request); 15 | } 16 | 17 | public Task HandleResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken) 18 | { 19 | Console.WriteLine("Request completed."); 20 | return Task.FromResult(response); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/NClient.Api/NClient.Api.Tests/Stubs/CustomLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.Logging; 3 | using NClient.Standalone.Client.Logging; 4 | 5 | namespace NClient.Api.Tests.Stubs 6 | { 7 | public class CustomLogger : ILogger 8 | { 9 | public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) 10 | { 11 | Console.WriteLine(state?.ToString()); 12 | } 13 | 14 | public bool IsEnabled(LogLevel logLevel) 15 | { 16 | return true; 17 | } 18 | 19 | public IDisposable BeginScope(TState state) 20 | { 21 | return new CompositeDisposable(Array.Empty()); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/NClient.Api/NClient.Api.Tests/Stubs/CustomResponseValidatorSettings.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using NClient.Providers.Validation; 3 | 4 | namespace NClient.Api.Tests.Stubs 5 | { 6 | public class CustomResponseValidatorSettings : ResponseValidatorSettings 7 | { 8 | public CustomResponseValidatorSettings() : base( 9 | isSuccess: _ => true, 10 | onFailure: _ => 11 | { 12 | }) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NClient.Extensions/NClient.Extensions.DependencyInjection.Tests/Helpers/ConstIntJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json; 3 | using System.Text.Json.Serialization; 4 | 5 | namespace NClient.Extensions.DependencyInjection.Tests.Helpers 6 | { 7 | public class ConstIntJsonConverter : JsonConverter 8 | { 9 | public int Value => int.MaxValue; 10 | 11 | public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 12 | { 13 | return Value; 14 | } 15 | 16 | public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options) 17 | { 18 | writer.WriteNumberValue(value); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/NClient.Extensions/NClient.Extensions.DependencyInjection.Tests/Helpers/LoggerFactoryMockFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Moq; 3 | 4 | namespace NClient.Extensions.DependencyInjection.Tests.Helpers 5 | { 6 | public static class LoggerFactoryMockFactory 7 | { 8 | public static Mock Create(Mock> loggerMock) 9 | { 10 | var loggerFactoryMock = new Mock(); 11 | loggerFactoryMock.Setup(x => x.CreateLogger(It.IsAny())).Returns(loggerMock.Object); 12 | return loggerFactoryMock; 13 | } 14 | 15 | public static void VerifyCreateLogger(this Mock mock, Times times) 16 | { 17 | mock.Verify(x => x.CreateLogger(typeof(T).FullName!), times); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/NClient.Providers/NClient.Providers.Serialization.MessagePack.Tests/Models/Dot.cs: -------------------------------------------------------------------------------- 1 | using MessagePack; 2 | 3 | namespace NClient.Providers.Serialization.MessagePack.Tests.Models 4 | { 5 | [MessagePackObject] 6 | public struct Dot 7 | { 8 | [Key(0)] 9 | public readonly int X; 10 | [Key(1)] 11 | public readonly int Y; 12 | 13 | [SerializationConstructor] 14 | public Dot(int x, int y) 15 | { 16 | X = x; 17 | Y = y; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/NClient.Providers/NClient.Providers.Serialization.MessagePack.Tests/Models/NotMP.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Serialization.MessagePack.Tests.Models 2 | { 3 | public struct NotMP 4 | { 5 | public readonly int X; 6 | public readonly int Y; 7 | 8 | public NotMP(int x, int y) 9 | { 10 | X = x; 11 | Y = y; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NClient.Providers/NClient.Providers.Serialization.MessagePack.Tests/Models/Point.cs: -------------------------------------------------------------------------------- 1 | using MessagePack; 2 | 3 | namespace NClient.Providers.Serialization.MessagePack.Tests.Models 4 | { 5 | [MessagePackObject] 6 | public readonly struct Point 7 | { 8 | [Key(0)] 9 | public readonly int X; 10 | 11 | [Key(1)] 12 | public readonly int Y; 13 | 14 | [SerializationConstructor] 15 | public Point(int x) 16 | { 17 | X = x; 18 | Y = -1; 19 | } 20 | 21 | public Point(int x, int y) 22 | { 23 | X = x; 24 | Y = y; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/NClient.Providers/NClient.Providers.Serialization.ProtobufNet.Tests/Models/NotProto.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Providers.Serialization.ProtobufNet.Tests.Models 2 | { 3 | public readonly struct NotProto 4 | { 5 | public readonly int X; 6 | public readonly int Y; 7 | 8 | public NotProto(int x, int y) 9 | { 10 | X = x; 11 | Y = y; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NClient.Providers/NClient.Providers.Serialization.ProtobufNet.Tests/Models/Point.cs: -------------------------------------------------------------------------------- 1 | using ProtoBuf; 2 | 3 | namespace NClient.Providers.Serialization.ProtobufNet.Tests.Models 4 | { 5 | [ProtoContract] 6 | public struct Point 7 | { 8 | [ProtoMember(1)] 9 | public int X { get; set; } 10 | [ProtoMember(2)] 11 | public int Y { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/NClient.Providers/NClient.Providers.Serialization.SystemTextJson.Tests/Contexts/BasicEntityJsonContext.cs: -------------------------------------------------------------------------------- 1 | #if NET6_0_OR_GREATER 2 | using System.Text.Json.Serialization; 3 | using NClient.Testing.Common.Entities; 4 | 5 | namespace NClient.Providers.Serialization.SystemTextJson.Tests.Contexts 6 | { 7 | [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] 8 | [JsonSerializable(typeof(BasicEntity))] 9 | internal partial class BasicEntityJsonContext : JsonSerializerContext 10 | { 11 | } 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/ClassClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace NClient.Testing.Common.Clients 4 | { 5 | public class ClassClient 6 | { 7 | public Task GetAsync(int id) 8 | { 9 | return Task.FromResult(1); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/ClassClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations.Http; 3 | 4 | namespace NClient.Testing.Common.Clients 5 | { 6 | // [Path("api/class")] - It is valid on 'Interface' declarations only. 7 | public class ClassClientWithMetadata 8 | { 9 | [GetMethod] 10 | public Task GetAsync(int id) 11 | { 12 | return Task.FromResult(1); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IAuthorizationClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace NClient.Testing.Common.Clients 4 | { 5 | public interface IAuthorizationClient : INClient 6 | { 7 | Task GetAsync(int id); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IAuthorizationClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | 5 | namespace NClient.Testing.Common.Clients 6 | { 7 | [Path("api/authorization")] 8 | public interface IAuthorizationClientWithMetadata : IAuthorizationClient 9 | { 10 | [GetMethod] 11 | new Task GetAsync(int id); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IBasicClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | using NClient.Testing.Common.Entities; 5 | 6 | namespace NClient.Testing.Common.Clients 7 | { 8 | [Path("api/basic")] 9 | public interface IBasicClientWithMetadata : IBasicClient 10 | { 11 | [GetMethod] 12 | new Task GetAsync(int id); 13 | 14 | [PostMethod] 15 | new Task PostAsync(BasicEntity entity); 16 | 17 | [PutMethod] 18 | new Task PutAsync(BasicEntity entity); 19 | 20 | [DeleteMethod] 21 | new Task DeleteAsync(int id); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/ICancellationClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace NClient.Testing.Common.Clients 5 | { 6 | public interface ICancellationClient 7 | { 8 | int Get(int id, CancellationToken cancellationToken); 9 | Task GetAsync(int id, CancellationToken cancellationToken); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/ICancellationClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using NClient.Annotations; 4 | using NClient.Annotations.Http; 5 | 6 | namespace NClient.Testing.Common.Clients 7 | { 8 | [Path("api/cancellation")] 9 | public interface ICancellationClientWithMetadata : ICancellationClient 10 | { 11 | [GetMethod] 12 | new int Get(int id, CancellationToken cancellationToken); 13 | 14 | [GetMethod] 15 | new Task GetAsync(int id, CancellationToken cancellationToken); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IFormUrlencodedClient.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using NClient.Providers.Transport; 4 | using NClient.Testing.Common.Entities; 5 | 6 | namespace NClient.Testing.Common.Clients 7 | { 8 | public interface IFormUrlencodedClient : INClient 9 | { 10 | Task PostAsync(int id); 11 | Task PostAsync(IDictionary dict); 12 | Task PostAsync(BasicEntity entity); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IFormUrlencodedClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using NClient.Annotations; 4 | using NClient.Annotations.Http; 5 | using NClient.Providers.Transport; 6 | using NClient.Testing.Common.Entities; 7 | 8 | namespace NClient.Testing.Common.Clients 9 | { 10 | [Path("api/formUrlencoded")] 11 | public interface IFormUrlencodedClientWithMetadata : IFormUrlencodedClient 12 | { 13 | [PostMethod] 14 | new Task PostAsync([FormParam] int id); 15 | 16 | [PostMethod] 17 | new Task PostAsync([FormParam] IDictionary dict); 18 | 19 | [PostMethod] 20 | new Task PostAsync([FormParam] BasicEntity entity); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IGenericClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | using NClient.Testing.Common.Entities; 5 | 6 | namespace NClient.Testing.Common.Clients 7 | { 8 | public interface IGenericClientWithMetadata : IGenericClientWithMetadataBase 9 | { 10 | } 11 | 12 | [Path("api/generic")] 13 | public interface IGenericClientWithMetadataBase 14 | { 15 | [PostMethod] 16 | Task PostAsync(TIn id); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IHttpResponseClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | using NClient.Providers.Results.HttpResults; 5 | using NClient.Testing.Common.Entities; 6 | 7 | namespace NClient.Testing.Common.Clients 8 | { 9 | [Path("api/http")] 10 | public interface IHttpResponseClientWithMetadata : IHttpResponseClient 11 | { 12 | [GetMethod] 13 | new Task> GetAsync(int id); 14 | 15 | [PostMethod] 16 | new Task> PostAsync(BasicEntity entity); 17 | 18 | [PutMethod] 19 | new Task PutAsync(BasicEntity entity); 20 | 21 | [DeleteMethod] 22 | new IHttpResponse Delete(int id); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IMultipartClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.AspNetCore.Http; 3 | using NClient.Models; 4 | using NClient.Providers.Transport; 5 | using NClient.Testing.Common.Entities; 6 | 7 | namespace NClient.Testing.Common.Clients 8 | { 9 | public interface IMultipartClient 10 | { 11 | Task PostWithStreamAsync(BasicEntity entity, IStreamContent stream); 12 | Task PostWithFileAsync(BasicEntity entity, IFormFile file); 13 | Task PostMultipartStreamContentAsync(IStreamContent streamContent1, IStreamContent streamContent2); 14 | Task PostMultipartFormFileAsync(IFormFile formFile1, IFormFile formFile2); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IOptionalParamClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Testing.Common.Entities; 3 | 4 | namespace NClient.Testing.Common.Clients 5 | { 6 | public interface IOptionalParamClient : INClient 7 | { 8 | /// 9 | /// Url: api/basic?id={id} 10 | /// Body: empty 11 | /// Headers: empty 12 | /// 13 | Task GetAsync(int id = 1); 14 | 15 | /// 16 | /// Url: api/basic 17 | /// Body: {entity} 18 | /// Headers: empty 19 | /// 20 | Task PostAsync(BasicEntity? entity = null); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IOptionalParamClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | using NClient.Testing.Common.Entities; 5 | 6 | namespace NClient.Testing.Common.Clients 7 | { 8 | [Path("api/optionalParam")] 9 | public interface IOptionalParamWithMetadata : IOptionalParamClient 10 | { 11 | [GetMethod] 12 | new Task GetAsync(int id = 1); 13 | 14 | [PostMethod] 15 | new Task PostAsync(BasicEntity? entity = null); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IResponseStreamClient.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading.Tasks; 3 | using NClient.Providers.Transport; 4 | 5 | namespace NClient.Testing.Common.Clients 6 | { 7 | public interface IResponseStreamClient 8 | { 9 | Task GetResponseAsync(); 10 | Task> GetResponseWithDataAsync(); 11 | Task> GetResponseWithErrorAsync(); 12 | Task> GetResponseWithDataOrErrorAsync(); 13 | Task GetStreamAsync(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IRestClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | using NClient.Testing.Common.Entities; 5 | 6 | namespace NClient.Testing.Common.Clients 7 | { 8 | [Path("api/rest")] 9 | public interface IRestClientWithMetadata : IRestClient 10 | { 11 | [GetMethod("{id}")] 12 | new Task GetAsync(int id); 13 | 14 | [GetMethod("{id}")] 15 | new Task GetAsync(string id); 16 | 17 | [PostMethod] 18 | new Task PostAsync(BasicEntity entity); 19 | 20 | [PutMethod] 21 | new Task PutAsync(BasicEntity entity); 22 | 23 | [DeleteMethod("{id}")] 24 | new Task DeleteAsync(int id); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IResultClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Testing.Common.Entities; 3 | 4 | namespace NClient.Testing.Common.Clients 5 | { 6 | public interface IResultClient : INClient 7 | { 8 | Task GetIntAsync(int id); 9 | 10 | Task GetEntityAsync(int id); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IResultClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | using NClient.Providers.Mapping.Results; 5 | using NClient.Testing.Common.Entities; 6 | 7 | namespace NClient.Testing.Common.Clients 8 | { 9 | [Path("api/result")] 10 | public interface IResultClientWithMetadata : IResultClient 11 | { 12 | [GetMethod("ints")] 13 | Task> GetIResultWithIntAsync(int id); 14 | 15 | [GetMethod("ints")] 16 | Task> GetResultWithIntAsync(int id); 17 | 18 | [GetMethod("entities")] 19 | Task> GetIResultWithEntityAsync(int id); 20 | 21 | [GetMethod("entities")] 22 | Task> GetResultWithEntityAsync(int id); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/IReturnClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Testing.Common.Entities; 3 | 4 | namespace NClient.Testing.Common.Clients 5 | { 6 | public interface IReturnClient : INClient 7 | { 8 | BasicEntity Get(int id); 9 | Task GetAsync(int id); 10 | 11 | void Post(BasicEntity entity); 12 | Task PostAsync(BasicEntity entity); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/ISyncClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using NClient.Annotations; 2 | using NClient.Annotations.Http; 3 | using NClient.Testing.Common.Entities; 4 | 5 | namespace NClient.Testing.Common.Clients 6 | { 7 | [Path("api/sync")] 8 | public interface ISyncClientWithMetadata : ISyncClient 9 | { 10 | [GetMethod] 11 | new int Get(int id); 12 | 13 | [PostMethod] 14 | new void Post(BasicEntity entity); 15 | 16 | [PutMethod] 17 | new void Put(BasicEntity entity); 18 | 19 | [DeleteMethod] 20 | new void Delete(int id); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/ITimeoutClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace NClient.Testing.Common.Clients 4 | { 5 | public interface ITimeoutClient : INClient 6 | { 7 | int Get(int id); 8 | Task GetAsync(int id); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/ITimeoutClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | 5 | namespace NClient.Testing.Common.Clients 6 | { 7 | [Path("api/timeout")] 8 | public interface ITimeoutClientWithMetadata : ITimeoutClient 9 | { 10 | [GetMethod] 11 | new int Get(int id); 12 | 13 | [GetMethod] 14 | new Task GetAsync(int id); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Clients/ITimeoutStaticClientWithMetadata.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using NClient.Annotations; 3 | using NClient.Annotations.Http; 4 | 5 | namespace NClient.Testing.Common.Clients 6 | { 7 | [Path("api/timeout")] 8 | [Timeout(500)] 9 | public interface ITimeoutStaticClientWithMetadata : ITimeoutClient 10 | { 11 | [GetMethod] 12 | [Timeout(1000)] 13 | new int Get(int id); 14 | 15 | [GetMethod] 16 | new Task GetAsync(int id); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/BasicEntity.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace NClient.Testing.Common.Entities 4 | { 5 | public class BasicEntity 6 | { 7 | [Required] 8 | public int Id { get; set; } 9 | public int Value { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/BasicEntityWithCustomFromQueryName.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace NClient.Testing.Common.Entities 4 | { 5 | public class BasicEntityWithCustomFromQueryName 6 | { 7 | [FromQuery(Name = "MyId")] 8 | public int Id { get; set; } 9 | public int Value { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/BasicEntityWithCustomJsonName.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace NClient.Testing.Common.Entities 4 | { 5 | public class BasicEntityWithCustomJsonName 6 | { 7 | [JsonPropertyName("MyId")] 8 | public int Id { get; set; } 9 | public int Value { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/BasicEntityWithCustomQueryName.cs: -------------------------------------------------------------------------------- 1 | using NClient.Annotations.Http; 2 | 3 | namespace NClient.Testing.Common.Entities 4 | { 5 | public class BasicEntityWithCustomQueryName 6 | { 7 | [QueryParam(Name = "MyId")] 8 | public int Id { get; set; } 9 | public int Value { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/EntityWithArray.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Testing.Common.Entities 2 | { 3 | public class EntityWithArray 4 | { 5 | public int Id { get; set; } 6 | public string? Value { get; set; } 7 | public int[]? Array { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/EntityWithCustomTypeArray.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Testing.Common.Entities 2 | { 3 | public class EntityWithCustomTypeArray 4 | { 5 | public int Id { get; set; } 6 | public string? Value { get; set; } 7 | public BasicEntity[]? Array { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/EntityWithCustomTypeDict.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NClient.Testing.Common.Entities 4 | { 5 | public class EntityWithCustomTypeDict 6 | { 7 | public int Id { get; set; } 8 | public string? Value { get; set; } 9 | public Dictionary? Dict { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/EntityWithDict.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NClient.Testing.Common.Entities 4 | { 5 | public class EntityWithDict 6 | { 7 | public int Id { get; set; } 8 | public string? Value { get; set; } 9 | public Dictionary? Dict { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/Error.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Testing.Common.Entities 2 | { 3 | public class Error 4 | { 5 | public string? Message { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/HttpError.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | 3 | namespace NClient.Testing.Common.Entities 4 | { 5 | public class HttpError 6 | { 7 | public HttpStatusCode Code { get; set; } 8 | public string? Message { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Entities/NestedEntity.cs: -------------------------------------------------------------------------------- 1 | namespace NClient.Testing.Common.Entities 2 | { 3 | public class NestedEntity 4 | { 5 | public int Id { get; set; } 6 | public string? Value { get; set; } 7 | public BasicEntity? InnerEntity { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/NClient.Testing/NClient.Testing.Common/Helpers/UriExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NClient.Testing.Common.Helpers 4 | { 5 | public static class UriExtensions 6 | { 7 | public static Uri ToUri(this string uri) 8 | { 9 | return new Uri(uri); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/NClient/NClient.InterfaceProxy.Tests/NClient.InterfaceProxy.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net5.0 5 | 9.0 6 | enable 7 | true 8 | true 9 | false 10 | Debug;Release;ReleaseTest 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tests/NClient/NClient.Standalone.Tests/Clients/IResponseStreamClient.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading.Tasks; 3 | using NClient.Annotations; 4 | using NClient.Annotations.Http; 5 | using NClient.Providers.Transport; 6 | using NClient.Testing.Common.Clients; 7 | 8 | namespace NClient.Standalone.Tests.Clients 9 | { 10 | [Path("api/responseStream")] 11 | public interface IResponseStreamClientWithMetaData : IResponseStreamClient 12 | { 13 | [GetMethod] 14 | new Task GetResponseAsync(); 15 | 16 | [GetMethod] 17 | new Task> GetResponseWithDataAsync(); 18 | 19 | [GetMethod] 20 | new Task> GetResponseWithErrorAsync(); 21 | 22 | [GetMethod] 23 | new Task> GetResponseWithDataOrErrorAsync(); 24 | 25 | [GetMethod] 26 | new Task GetStreamAsync(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/NClient/NClient.Tests/ClientFactoryTests/Helpers/ClientTestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AutoFixture; 3 | using FluentAssertions; 4 | using NUnit.Framework; 5 | 6 | namespace NClient.Tests.ClientFactoryTests.Helpers 7 | { 8 | public abstract class ClientFactoryTestBase 9 | { 10 | protected readonly Fixture Fixture = new Lazy(() => 11 | { 12 | var fixture = new Fixture(); 13 | fixture.Inject(new UriScheme("http")); 14 | return fixture; 15 | }).Value; 16 | 17 | [Test, Order(-1)] 18 | public virtual void Build_CustomFactory_Validate() 19 | { 20 | var factoryName = Fixture.Create(); 21 | 22 | NClientGallery.ClientFactories.GetRest().For(factoryName) 23 | .Invoking(builder => builder.Build()) 24 | .Should() 25 | .NotThrow(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/NClient/NClient.Tests/ClientTests/Helpers/ClientTestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AutoFixture; 3 | using FluentAssertions; 4 | using NUnit.Framework; 5 | 6 | namespace NClient.Tests.ClientTests.Helpers 7 | { 8 | public abstract class ClientTestBase where TClient : class 9 | { 10 | protected readonly Fixture Fixture = new Lazy(() => 11 | { 12 | var fixture = new Fixture(); 13 | fixture.Inject(new UriScheme("http")); 14 | return fixture; 15 | }).Value; 16 | 17 | [Test, Order(-1)] 18 | public virtual void Build_CustomClientType_Validate() 19 | { 20 | var uri = Fixture.Create(); 21 | 22 | NClientGallery.Clients.GetRest().For(uri) 23 | .Invoking(builder => builder.Build()) 24 | .Should() 25 | .NotThrow(); 26 | } 27 | } 28 | } 29 | --------------------------------------------------------------------------------