/// <summary> /// Extension method to process the result of a server method operation without result value. /// </summary> /// <param name="source"> The InvokeServerMethodOperation returned from InvokeServerMethodAsync() </param> /// <param name="onSuccess"> A callback to be called if the server method was successful. </param> /// <param name="onFail"> A callback to be called if the server method failed. </param> /// <returns> Returns the InvokeServerMethodOperation passed to the method's source parameter. </returns> public static InvokeServerMethodOperation OnComplete(this InvokeServerMethodOperation source, Action onSuccess, Action <Exception> onFail) { source.Completed += (s, args) => { if (args.CompletedSuccessfully) { if (onSuccess != null) { onSuccess(); } } 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 <object> GetAwaiter(this InvokeServerMethodOperation operation) { return(operation.AsOperationResult <object>().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 <T> AsOperationResult <T>(this InvokeServerMethodOperation asyncOp) { return(new InvokeServerMethodOperationResult <T>(asyncOp)); }
public InvokeServerMethodOperationResult(InvokeServerMethodOperation invokeServerMethodOperation) : base(invokeServerMethodOperation) { _invokeServerMethodOperation = invokeServerMethodOperation; }