Class Attempt
Provides ways to create attempts.
Inheritance
Namespace: Umbraco.Core
Assembly: Umbraco.Core.dll
Syntax
public static class Attempt
Methods
View SourceFail<TResult>()
Creates a failed attempt.
Declaration
public static Attempt<TResult> Fail<TResult>()
Returns
Type | Description |
---|---|
Attempt<TResult> | The failed attempt. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the attempted operation result. |
Fail<TResult>(TResult)
Creates a failed attempt with a result.
Declaration
public static Attempt<TResult> Fail<TResult>(TResult result)
Parameters
Type | Name | Description |
---|---|---|
TResult | result | The result of the attempt. |
Returns
Type | Description |
---|---|
Attempt<TResult> | The failed attempt. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the attempted operation result. |
Fail<TResult>(TResult, Exception)
Creates a failed attempt with a result and an exception.
Declaration
public static Attempt<TResult> Fail<TResult>(TResult result, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
TResult | result | The result of the attempt. |
System.Exception | exception | The exception causing the failure of the attempt. |
Returns
Type | Description |
---|---|
Attempt<TResult> | The failed attempt. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the attempted operation result. |
FailWithStatus<TResult, TStatus>(TStatus, TResult)
Creates a failed attempt with a result and a status.
Declaration
public static Attempt<TResult, TStatus> FailWithStatus<TResult, TStatus>(TStatus status, TResult result)
Parameters
Type | Name | Description |
---|---|---|
TStatus | status | The status of the attempt. |
TResult | result | The result of the attempt. |
Returns
Type | Description |
---|---|
Attempt<TResult, TStatus> | The failed attempt. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the attempted operation result. |
TStatus | The type of the attempted operation status. |
FailWithStatus<TResult, TStatus>(TStatus, TResult, Exception)
Creates a failed attempt with a result, an exception and a status.
Declaration
public static Attempt<TResult, TStatus> FailWithStatus<TResult, TStatus>(TStatus status, TResult result, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
TStatus | status | The status of the attempt. |
TResult | result | The result of the attempt. |
System.Exception | exception | The exception causing the failure of the attempt. |
Returns
Type | Description |
---|---|
Attempt<TResult, TStatus> | The failed attempt. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the attempted operation result. |
TStatus | The type of the attempted operation status. |
If<TResult>(Boolean, TResult)
Creates a successful or a failed attempt, with a result.
Declaration
public static Attempt<TResult> If<TResult>(bool condition, TResult result)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | condition | A value indicating whether the attempt is successful. |
TResult | result | The result of the attempt. |
Returns
Type | Description |
---|---|
Attempt<TResult> | The attempt. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the attempted operation result. |
IfWithStatus<TResult, TStatus>(Boolean, TStatus, TStatus, TResult)
Creates a successful or a failed attempt, with a result.
Declaration
public static Attempt<TResult, TStatus> IfWithStatus<TResult, TStatus>(bool condition, TStatus succStatus, TStatus failStatus, TResult result)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | condition | A value indicating whether the attempt is successful. |
TStatus | succStatus | The status of the successful attempt. |
TStatus | failStatus | The status of the failed attempt. |
TResult | result | The result of the attempt. |
Returns
Type | Description |
---|---|
Attempt<TResult, TStatus> | The attempt. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the attempted operation result. |
TStatus | The type of the attempted operation status. |
Succeed<TResult>(TResult)
Creates a successful attempt with a result.
Declaration
public static Attempt<TResult> Succeed<TResult>(TResult result)
Parameters
Type | Name | Description |
---|---|---|
TResult | result | The result of the attempt. |
Returns
Type | Description |
---|---|
Attempt<TResult> | The successful attempt. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the attempted operation result. |
SucceedWithStatus<TResult, TStatus>(TStatus, TResult)
Creates a successful attempt with a result and a status.
Declaration
public static Attempt<TResult, TStatus> SucceedWithStatus<TResult, TStatus>(TStatus status, TResult result)
Parameters
Type | Name | Description |
---|---|---|
TStatus | status | The status of the attempt. |
TResult | result | The result of the attempt. |
Returns
Type | Description |
---|---|
Attempt<TResult, TStatus> | The successful attempt. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the attempted operation result. |
TStatus | The type of the attempted operation status. |