Show / Hide Table of Contents

Interface IElementEndpoint<TEntity>

Endpoint for an individual resource.

Inherited Members
IElementEndpoint.ExistsAsync(CancellationToken)
IElementEndpoint.DeleteAsync(CancellationToken)
IElementEndpoint.DeleteAllowed
IEndpoint.GetLinks(String)
IEndpoint.Link(String)
IEndpoint.LinkTemplate(String, IDictionary<String, Object>)
IEndpoint.LinkTemplate(String, Object)
IEndpoint.Uri
IEndpoint.HttpClient
IEndpoint.Serializer
IEndpoint.ErrorHandler
IEndpoint.LinkExtractor
Namespace: TypedRest.Endpoints.Generic
Assembly: TypedRest.dll
Syntax
public interface IElementEndpoint<TEntity> : IElementEndpoint, IEndpoint where TEntity : class
Type Parameters
Name Description
TEntity

The type of entity the endpoint represents.

Properties

MergeAllowed

Shows whether the server has indicated that MergeAsync(TEntity, CancellationToken) is currently allowed.

Declaration
Nullable<bool> MergeAllowed { get; }
Property Value
Type Description
Nullable<Boolean>

true if the method is allowed, false if the method is not allowed, null If no request has been sent yet or the server did not specify allowed methods.

Remarks

Uses cached data from last response.

Response

A cached copy of the entity as received from the server.

Declaration
TEntity Response { get; }
Property Value
Type Description
TEntity

SetAllowed

Shows whether the server has indicated that SetAsync(TEntity, CancellationToken) is currently allowed.

Declaration
Nullable<bool> SetAllowed { get; }
Property Value
Type Description
Nullable<Boolean>

true if the method is allowed, false if the method is not allowed, null If no request has been sent yet or the server did not specify allowed methods.

Remarks

Uses cached data from last response.

Methods

MergeAsync(TEntity, CancellationToken)

Modifies an existing TEntity by merging changes on the server-side.

Declaration
Task<TEntity> MergeAsync(TEntity entity, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TEntity entity

The TEntity data to merge with the existing one.

CancellationToken cancellationToken

Used to cancel the request.

Returns
Type Description
Task<TEntity>

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

Exceptions
Type Condition
InvalidOperationException

The entity has changed since it was last retrieved with ReadAsync(CancellationToken). Your changes were rejected to prevent a lost update.

InvalidDataException BadRequest
AuthenticationException Unauthorized
UnauthorizedAccessException Forbidden
KeyNotFoundException NotFound or Gone
HttpRequestException

Other non-success status code.

ReadAsync(CancellationToken)

Returns the TEntity.

Declaration
Task<TEntity> ReadAsync(CancellationToken cancellationToken = null)
Parameters
Type Name Description
CancellationToken cancellationToken

Used to cancel the request.

Returns
Type Description
Task<TEntity>
Exceptions
Type Condition
AuthenticationException Unauthorized
UnauthorizedAccessException Forbidden
KeyNotFoundException NotFound or Gone
HttpRequestException

Other non-success status code.

SetAsync(TEntity, CancellationToken)

Sets/replaces the TEntity.

Declaration
Task<TEntity> SetAsync(TEntity entity, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TEntity entity

The new TEntity.

CancellationToken cancellationToken

Used to cancel the request.

Returns
Type Description
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.

Exceptions
Type Condition
InvalidOperationException

The entity has changed since it was last retrieved with ReadAsync(CancellationToken). Your changes were rejected to prevent a lost update.

InvalidDataException BadRequest
AuthenticationException Unauthorized
UnauthorizedAccessException Forbidden
KeyNotFoundException NotFound or Gone
HttpRequestException

Other non-success status code.

UpdateAsync(Action<TEntity>, Int32, CancellationToken)

Reads the current state of the entity, applies a change to it and stores the result. Applies optimistic concurrency using automatic retries.

Declaration
Task<TEntity> UpdateAsync(Action<TEntity> updateAction, int maxRetries = 3, CancellationToken cancellationToken = null)
Parameters
Type Name Description
Action<TEntity> updateAction

A callback that takes the current state of the entity and applies the desired modifications.

Int32 maxRetries

The maximum number of retries to perform for optimistic concurrency before giving up.

CancellationToken cancellationToken

Used to cancel the request.

Returns
Type Description
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.

Exceptions
Type Condition
InvalidOperationException

The number of retries performed for optimistic concurrency exceeded maxRetries.

InvalidDataException BadRequest
AuthenticationException Unauthorized
UnauthorizedAccessException Forbidden
KeyNotFoundException NotFound or Gone
HttpRequestException

Other non-success status code.

UpdateAsync(Action<JsonPatchDocument<TEntity>>, Int32, CancellationToken)

Applies a JSON Patch to the entity. Sends the patch instructions to the server for processing; falls back to local processing with optimistic concurrency if that fails.

Declaration
Task<TEntity> UpdateAsync(Action<JsonPatchDocument<TEntity>> patchAction, int maxRetries = 3, CancellationToken cancellationToken = null)
Parameters
Type Name Description
Action<JsonPatchDocument<TEntity>> patchAction

Callback for building a patch document describing the desired modifications.

Int32 maxRetries

The maximum number of retries to perform for optimistic concurrency before giving up.

CancellationToken cancellationToken

Used to cancel the request.

Returns
Type Description
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.

Exceptions
Type Condition
InvalidOperationException

The number of retries performed for optimistic concurrency exceeded maxRetries.

NotSupportedException

Serializer is not a JsonMediaTypeFormatter.

InvalidDataException BadRequest
AuthenticationException Unauthorized
UnauthorizedAccessException Forbidden
KeyNotFoundException NotFound or Gone
HttpRequestException

Other non-success status code.

In This Article
Back to top Copyright Bastian Eicher