/// <summary> /// Extension method to process the result of a refetch operation. /// </summary> /// <param name="source"> The EntityRefetchOperation returned from an asynchronous refetch operation."/> </param> /// <param name="onSuccess"> A callback to be called if the refetch was successful. </param> /// <param name="onFail"> A callback to be called if the refetch failed. </param> /// <returns> Returns the EntityRefetchOperation passed to the method's source parameter. </returns> public static EntityRefetchOperation OnComplete(this EntityRefetchOperation source, Action <IEnumerable> onSuccess, Action <Exception> onFail) { source.Completed += (s, args) => { if (args.CompletedSuccessfully) { if (onSuccess != null) { onSuccess(args.Results); } } if (args.HasError && !args.IsErrorHandled && onFail != null) { args.MarkErrorAsHandled(); onFail(args.Error); } }; return(source); }
/// <summary> /// Gets an awaiter used to await this operation. /// </summary> /// <param name="operation"> The operation to await. </param> public static TaskAwaiter <IEnumerable> GetAwaiter(this EntityRefetchOperation operation) { return(operation.AsOperationResult().GetAwaiter()); }
/// <summary> /// Returns an implementation of <see cref="OperationResult{T}" /> that wraps a DevForce asynchronous function and provides access to the operation's result value. /// </summary> /// <param name="asyncOp"> DevForce asynchronous operation. </param> /// <returns> OperationResult encapsulating the provided DevForce asynchronous operation. </returns> public static OperationResult <IEnumerable> AsOperationResult(this EntityRefetchOperation asyncOp) { return(new EntityRefetchOperationResult(asyncOp)); }
public EntityRefetchOperationResult(EntityRefetchOperation entityRefetchOperation) : base(entityRefetchOperation) { _entityRefetchOperation = entityRefetchOperation; }