Table of Contents

Class AbstractAddressValidationService<TRequest, TApiResponse>

Namespace
Visus.AddressValidation.Services
Assembly
Visus.AddressValidation.dll

Abstract base class for implementing an IAddressValidationService<TRequest>.

public abstract class AbstractAddressValidationService<TRequest, TApiResponse> : IAddressValidationService<TRequest> where TRequest : AbstractAddressValidationRequest where TApiResponse : class

Type Parameters

TRequest

The type of the validation request. Must derive from AbstractAddressValidationRequest.

TApiResponse

The type of the raw response returned by the underlying service API. Mapped to an IAddressValidationResponse by an IApiResponseMapper<TResponse>.

Inheritance
AbstractAddressValidationService<TRequest, TApiResponse>
Implements
Inherited Members

Constructors

AbstractAddressValidationService(IApiRequestAdapter<TRequest, TApiResponse>, IApiResponseMapper<TApiResponse>, IValidator<TRequest>, IValidator<TApiResponse>)

protected AbstractAddressValidationService(IApiRequestAdapter<TRequest, TApiResponse> requestAdapter, IApiResponseMapper<TApiResponse> responseMapper, IValidator<TRequest> requestValidator, IValidator<TApiResponse> responseValidator)

Parameters

requestAdapter IApiRequestAdapter<TRequest, TApiResponse>

An IApiRequestAdapter<TRequest, TApiResponse> used to forward TRequest instances to the underlying API and return the raw TApiResponse.

responseMapper IApiResponseMapper<TApiResponse>

An IApiResponseMapper<TResponse> used to map TApiResponse instances to an IAddressValidationResponse.

requestValidator IValidator<TRequest>

An IValidator<T> used to validate TRequest instances before they are sent to the underlying API.

responseValidator IValidator<TApiResponse>

An IValidator<T> used to validate TApiResponse instances returned by the underlying API.

Exceptions

ArgumentNullException

Thrown when requestAdapter, responseMapper, requestValidator, or responseValidator is null.

InvalidImplementationException

Thrown when requestValidator does not derive from AbstractAddressValidationRequestValidator<T>.

Methods

ValidateAsync(TRequest, CancellationToken)

Validates the request instance asynchronously.

public Task<IAddressValidationResponse?> ValidateAsync(TRequest request, CancellationToken cancellationToken = default)

Parameters

request TRequest

Request to be validated represented as an instance of TRequest.

cancellationToken CancellationToken

A cancellation token that can be used to cancel the work.

Returns

Task<IAddressValidationResponse>

Result of the validation as represented by an instance of IAddressValidationResponse.

Remarks

The instance IAddressValidationResponse may be null if the request or validation failed.