Struct Attempt.Outcome
Represents the outcome of an attempt.
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public struct Outcome
Remarks
Can be a success or a failure, and allows for attempts chaining.
Fields
Failure
Gets an outcome representing a failure.
Declaration
public static readonly Attempt.Outcome Failure
Field Value
Type | Description |
---|---|
Attempt.Outcome |
Success
Gets an outcome representing a success.
Declaration
public static readonly Attempt.Outcome Success
Field Value
Type | Description |
---|---|
Attempt.Outcome |
Methods
OnFailure<T>(Func<Attempt<T>>, Action<T>, Action<Exception>)
Executes another attempt function, if the previous one failed, with callbacks.
Declaration
public Attempt.Outcome OnFailure<T>(Func<Attempt<T>> nextFunction, Action<T> onSuccess, Action<Exception> onFail = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<Attempt<T>> | nextFunction | The attempt function to execute, returning an attempt. |
System.Action<T> | onSuccess | An action to execute in case the attempt succeeds. |
System.Action<System.Exception> | onFail | An action to execute in case the attempt fails. |
Returns
Type | Description |
---|---|
Attempt.Outcome | If it executes, returns the outcome of the attempt, else returns a success outcome. |
Type Parameters
Name | Description |
---|---|
T | The type of the attempted operation result. |
Remarks
Executes only if the previous attempt failed, else does not execute and return a success outcome.
If it executes, then runs onSuccess or onFail depending on the whether the attempt function reports a success or a failure.
OnSuccess<T>(Func<Attempt<T>>, Action<T>, Action<Exception>)
Executes another attempt function, if the previous one succeeded, with callbacks.
Declaration
public Attempt.Outcome OnSuccess<T>(Func<Attempt<T>> nextFunction, Action<T> onSuccess, Action<Exception> onFail = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<Attempt<T>> | nextFunction | The attempt function to execute, returning an attempt. |
System.Action<T> | onSuccess | An action to execute in case the attempt succeeds. |
System.Action<System.Exception> | onFail | An action to execute in case the attempt fails. |
Returns
Type | Description |
---|---|
Attempt.Outcome | If it executes, returns the outcome of the attempt, else returns a failed outcome. |
Type Parameters
Name | Description |
---|---|
T | The type of the attempted operation result. |
Remarks
Executes only if the previous attempt succeeded, else does not execute and return a success outcome.
If it executes, then runs onSuccess or onFail depending on the whether the attempt function reports a success or a failure.