Table of Contents

Class CollectionEndpointExtensions

Namespace
TypedRest.Endpoints.Generic
Assembly
TypedRest.dll
public static class CollectionEndpointExtensions
Inheritance
CollectionEndpointExtensions
Inherited Members

Methods

ContainsAsync<TElementEndpoint>(IIndexerEndpoint<TElementEndpoint>, string, CancellationToken)

Determines whether the collection contains a specific element.

public static Task<bool> ContainsAsync<TElementEndpoint>(this IIndexerEndpoint<TElementEndpoint> endpoint, string id, CancellationToken cancellationToken = default) where TElementEndpoint : IElementEndpoint

Parameters

endpoint IIndexerEndpoint<TElementEndpoint>

The collection endpoint containing the element.

id string

The ID identifying the entity in the collection.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task<bool>

Type Parameters

TElementEndpoint

The type of IEndpoint to provide for individual entity.

Remarks

This is a convenience method equivalent to combining this[string] with ExistsAsync(CancellationToken).

Exceptions

AuthenticationException

Unauthorized

UnauthorizedAccessException

Forbidden

HttpRequestException

Other non-success status code.

ContainsAsync<TEntity, TElementEndpoint>(ICollectionEndpoint<TEntity, TElementEndpoint>, TEntity, CancellationToken)

Determines whether the collection contains a specific element.

public static Task<bool> ContainsAsync<TEntity, TElementEndpoint>(this ICollectionEndpoint<TEntity, TElementEndpoint> endpoint, TEntity element, CancellationToken cancellationToken = default) where TEntity : class where TElementEndpoint : IElementEndpoint<TEntity>

Parameters

endpoint ICollectionEndpoint<TEntity, TElementEndpoint>

The collection endpoint containing the element.

element TEntity

The element to be checked.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task<bool>

Type Parameters

TEntity

The type of individual elements in the collection.

TElementEndpoint

The type of IEndpoint to provide for individual TEntitys.

Remarks

This is a convenience method equivalent to combining this[TEntity] with ExistsAsync(CancellationToken).

Exceptions

AuthenticationException

Unauthorized

UnauthorizedAccessException

Forbidden

HttpRequestException

Other non-success status code.

DeleteAsync<TElementEndpoint>(IIndexerEndpoint<TElementEndpoint>, string, CancellationToken)

Deletes an existing element from the collection.

public static Task DeleteAsync<TElementEndpoint>(this IIndexerEndpoint<TElementEndpoint> endpoint, string id, CancellationToken cancellationToken = default) where TElementEndpoint : IElementEndpoint

Parameters

endpoint IIndexerEndpoint<TElementEndpoint>

The collection endpoint containing the element.

id string

The ID identifying the entity in the collection.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task

Type Parameters

TElementEndpoint

The type of IEndpoint to provide for individual entities.

Remarks

This is a convenience method equivalent to combining this[string] with DeleteAsync(CancellationToken).

Exceptions

AuthenticationException

Unauthorized

UnauthorizedAccessException

Forbidden

KeyNotFoundException

NotFound or Gone

HttpRequestException

Other non-success status code.

DeleteAsync<TEntity, TElementEndpoint>(ICollectionEndpoint<TEntity, TElementEndpoint>, TEntity, CancellationToken)

Deletes an existing element from the collection.

public static Task DeleteAsync<TEntity, TElementEndpoint>(this ICollectionEndpoint<TEntity, TElementEndpoint> endpoint, TEntity element, CancellationToken cancellationToken = default) where TEntity : class where TElementEndpoint : IElementEndpoint<TEntity>

Parameters

endpoint ICollectionEndpoint<TEntity, TElementEndpoint>

The collection endpoint containing the element.

element TEntity

The element to be deleted.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task

Type Parameters

TEntity

The type of individual elements in the collection.

TElementEndpoint

The type of IEndpoint to provide for individual TEntitys.

Remarks

This is a convenience method equivalent to combining this[TEntity] with DeleteAsync(CancellationToken).

Exceptions

AuthenticationException

Unauthorized

UnauthorizedAccessException

Forbidden

KeyNotFoundException

NotFound or Gone

HttpRequestException

Other non-success status code.

MergeAsync<TEntity, TElementEndpoint>(ICollectionEndpoint<TEntity, TElementEndpoint>, TEntity, CancellationToken)

Modifies an existing element in the collection by merging changes on the server-side.

public static Task<TEntity?> MergeAsync<TEntity, TElementEndpoint>(this ICollectionEndpoint<TEntity, TElementEndpoint> endpoint, TEntity element, CancellationToken cancellationToken = default) where TEntity : class where TElementEndpoint : IElementEndpoint<TEntity>

Parameters

endpoint ICollectionEndpoint<TEntity, TElementEndpoint>

The collection endpoint containing the element.

element TEntity

The TEntity data to merge with the existing element.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task<TEntity>

The TEntity as returned by the server, possibly with additional fields set. null if the server does not respond with a result entity.

Type Parameters

TEntity

The type of individual elements in the collection.

TElementEndpoint

The type of IEndpoint to provide for individual TEntitys.

Remarks

This is a convenience method equivalent to combining this[TEntity] with SetAsync(TEntity, CancellationToken).

Exceptions

InvalidDataException

BadRequest

AuthenticationException

Unauthorized

UnauthorizedAccessException

Forbidden

KeyNotFoundException

NotFound or Gone

HttpRequestException

Other non-success status code.

SetAsync<TEntity, TElementEndpoint>(ICollectionEndpoint<TEntity, TElementEndpoint>, TEntity, CancellationToken)

Sets/replaces an existing element in the collection.

public static Task<TEntity?> SetAsync<TEntity, TElementEndpoint>(this ICollectionEndpoint<TEntity, TElementEndpoint> endpoint, TEntity element, CancellationToken cancellationToken = default) where TEntity : class where TElementEndpoint : IElementEndpoint<TEntity>

Parameters

endpoint ICollectionEndpoint<TEntity, TElementEndpoint>

The collection endpoint containing the element.

element TEntity

The new state of the element.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task<TEntity>

The TEntity as returned by the server, possibly with additional fields set. null if the server does not respond with a result entity.

Type Parameters

TEntity

The type of individual elements in the collection.

TElementEndpoint

The type of IEndpoint to provide for individual TEntitys.

Remarks

This is a convenience method equivalent to combining this[TEntity] with SetAsync(TEntity, CancellationToken).

Exceptions

InvalidDataException

BadRequest

AuthenticationException

Unauthorized

UnauthorizedAccessException

Forbidden

KeyNotFoundException

NotFound or Gone

HttpRequestException

Other non-success status code.