Table of Contents

Class CollectionEndpointExtensions

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

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 : notnull, IElementEndpoint

Parameters

endpoint IIndexerEndpoint<TElementEndpoint>
id string

The ID identifying the entity in the collection.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task<bool>

Type Parameters

TElementEndpoint

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 : notnull, IElementEndpoint<TEntity>

Parameters

endpoint ICollectionEndpoint<TEntity, TElementEndpoint>
element TEntity

The element to be checked.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task<bool>

Type Parameters

TEntity
TElementEndpoint

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 : notnull, IElementEndpoint

Parameters

endpoint IIndexerEndpoint<TElementEndpoint>
id string

The ID identifying the entity in the collection.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task

Type Parameters

TElementEndpoint

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 : notnull, IElementEndpoint<TEntity>

Parameters

endpoint ICollectionEndpoint<TEntity, TElementEndpoint>
element TEntity

The element to be deleted.

cancellationToken CancellationToken

Used to cancel the request.

Returns

Task

Type Parameters

TEntity
TElementEndpoint

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 : notnull, IElementEndpoint<TEntity>

Parameters

endpoint ICollectionEndpoint<TEntity, TElementEndpoint>
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
TElementEndpoint

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 : notnull, IElementEndpoint<TEntity>

Parameters

endpoint ICollectionEndpoint<TEntity, TElementEndpoint>
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
TElementEndpoint

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.