IOperation
interface IOperation
An interface used by OperationInternal for making service calls and updating state. It's expected that
your long-running operation classes implement this interface.
Get a token that can be used to rehydrate the operation.
Calls the service and updates the state of the long-running operation. Properties directly handled by the
OperationInternal class, such as RawResponse
don't need to be updated. Operation-specific properties, such as "CreateOn" or "LastModified",
must be manually updated by the operation implementing this method.
Usage example:
async ValueTask<OperationState> IOperation.UpdateStateAsync(bool async, CancellationToken cancellationToken)
{
Response<R> response = async ? <async service call> : <sync service call>;
if (<operation succeeded>) return OperationState.Success(response.GetRawResponse(), <parse response>);
if (<operation failed>) return OperationState.Failure(response.GetRawResponse());
return OperationState.Pending(response.GetRawResponse());
}