Class OperationResult.Attempt
Provides factory methods for creating Attempt<TResult> instances wrapping OperationResult objects.
Inheritance
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public static class OperationResult.Attempt
Remarks
This static class exists to support services that still return Attempt<OperationResult>.
These services should directly return an OperationResult, and then this static class should be deleted.
Methods
View SourceCancel(EventMessages)
Creates a failed operation attempt indicating that the operation has been cancelled.
Declaration
public static Attempt<OperationResult?> Cancel(EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | A new attempt instance. |
Cancel<TValue>(EventMessages)
Creates a failed operation attempt indicating that the operation was cancelled, with a typed value.
Declaration
public static Attempt<OperationResult<OperationResultType, TValue>?> Cancel<TValue>(EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, TValue>> | A new attempt instance indicating cancellation. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the entity value. |
Cancel<TValue>(EventMessages, TValue)
Creates a failed operation attempt indicating that the operation was cancelled, with a typed value and entity.
Declaration
public static Attempt<OperationResult<OperationResultType, TValue>?> Cancel<TValue>(EventMessages eventMessages, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
| TValue | value | The entity value associated with the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, TValue>> | A new attempt instance indicating cancellation. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the entity value. |
Cannot<TValue>(EventMessages)
Creates a failed operation attempt indicating that the operation cannot be performed.
Declaration
public static Attempt<OperationResult<OperationResultType, TValue>?> Cannot<TValue>(EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, TValue>> | A new attempt instance indicating the operation cannot be performed. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the entity value. |
Fail(EventMessages, Exception)
Creates a failed operation attempt indicating that an exception was thrown during the operation.
Declaration
public static Attempt<OperationResult?> Fail(EventMessages eventMessages, Exception exception)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
| Exception | exception | The exception that caused the operation to fail. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | A new attempt instance. |
Fail<TValue>(EventMessages, Exception)
Creates a failed operation attempt indicating that an exception was thrown, with a typed value.
Declaration
public static Attempt<OperationResult<OperationResultType, TValue>?> Fail<TValue>(EventMessages eventMessages, Exception exception)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
| Exception | exception | The exception that caused the operation to fail. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, TValue>> | A new attempt instance indicating failure due to an exception. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the entity value. |
Fail<TStatusType>(TStatusType, EventMessages)
Creates a failed operation attempt with a custom status type.
Declaration
public static Attempt<OperationResult<TStatusType>?> Fail<TStatusType>(TStatusType statusType, EventMessages eventMessages) where TStatusType : struct
Parameters
| Type | Name | Description |
|---|---|---|
| TStatusType | statusType | The status type indicating the failure reason. |
| EventMessages | eventMessages | The event messages produced by the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<TStatusType>> | A new attempt instance indicating failure. |
Type Parameters
| Name | Description |
|---|---|
| TStatusType | The type of the status enumeration. |
Fail<TStatusType>(TStatusType, EventMessages, Exception)
Creates a failed operation attempt with a custom status type and exception.
Declaration
public static Attempt<OperationResult<TStatusType>?> Fail<TStatusType>(TStatusType statusType, EventMessages eventMessages, Exception exception) where TStatusType : struct
Parameters
| Type | Name | Description |
|---|---|---|
| TStatusType | statusType | The status type indicating the failure reason. |
| EventMessages | eventMessages | The event messages produced by the operation. |
| Exception | exception | The exception that caused the operation to fail. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<TStatusType>> | A new attempt instance indicating failure. |
Type Parameters
| Name | Description |
|---|---|
| TStatusType | The type of the status enumeration. |
Fail<TStatusType, TValue>(TStatusType, EventMessages)
Creates a failed operation attempt with a custom status type and typed value.
Declaration
public static Attempt<OperationResult<TStatusType, TValue>?> Fail<TStatusType, TValue>(TStatusType statusType, EventMessages eventMessages) where TStatusType : struct
Parameters
| Type | Name | Description |
|---|---|---|
| TStatusType | statusType | The status type indicating the failure reason. |
| EventMessages | eventMessages | The event messages produced by the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<TStatusType, TValue>> | A new attempt instance indicating failure. |
Type Parameters
| Name | Description |
|---|---|
| TStatusType | The type of the status enumeration. |
| TValue | The type of the entity value. |
Fail<TStatusType, TValue>(TStatusType, EventMessages, Exception)
Creates a failed operation attempt with a custom status type, typed value, and exception.
Declaration
public static Attempt<OperationResult<TStatusType, TValue>?> Fail<TStatusType, TValue>(TStatusType statusType, EventMessages eventMessages, Exception exception) where TStatusType : struct
Parameters
| Type | Name | Description |
|---|---|---|
| TStatusType | statusType | The status type indicating the failure reason. |
| EventMessages | eventMessages | The event messages produced by the operation. |
| Exception | exception | The exception that caused the operation to fail. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<TStatusType, TValue>> | A new attempt instance indicating failure. |
Type Parameters
| Name | Description |
|---|---|
| TStatusType | The type of the status enumeration. |
| TValue | The type of the entity value. |
Fail<TStatusType, TValue>(TStatusType, EventMessages, TValue)
Creates a failed operation attempt with a custom status type, typed value, and entity.
Declaration
public static Attempt<OperationResult<TStatusType, TValue>?> Fail<TStatusType, TValue>(TStatusType statusType, EventMessages eventMessages, TValue value) where TStatusType : struct
Parameters
| Type | Name | Description |
|---|---|---|
| TStatusType | statusType | The status type indicating the failure reason. |
| EventMessages | eventMessages | The event messages produced by the operation. |
| TValue | value | The entity value associated with the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<TStatusType, TValue>> | A new attempt instance indicating failure. |
Type Parameters
| Name | Description |
|---|---|
| TStatusType | The type of the status enumeration. |
| TValue | The type of the entity value. |
Fail<TStatusType, TValue>(TStatusType, EventMessages, TValue, Exception)
Creates a failed operation attempt with a custom status type, typed value, entity, and exception.
Declaration
public static Attempt<OperationResult<TStatusType, TValue>?> Fail<TStatusType, TValue>(TStatusType statusType, EventMessages eventMessages, TValue value, Exception exception) where TStatusType : struct
Parameters
| Type | Name | Description |
|---|---|---|
| TStatusType | statusType | The status type indicating the failure reason. |
| EventMessages | eventMessages | The event messages produced by the operation. |
| TValue | value | The entity value associated with the operation. |
| Exception | exception | The exception that caused the operation to fail. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<TStatusType, TValue>> | A new attempt instance indicating failure. |
Type Parameters
| Name | Description |
|---|---|
| TStatusType | The type of the status enumeration. |
| TValue | The type of the entity value. |
NoOperation(EventMessages)
Creates a successful operation attempt indicating that nothing was done.
Declaration
public static Attempt<OperationResult?> NoOperation(EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | A new attempt instance. |
Succeed(EventMessages)
Creates a successful operation attempt.
Declaration
public static Attempt<OperationResult?> Succeed(EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | A new attempt instance. |
Succeed<TValue>(EventMessages)
Creates a successful operation attempt with a typed value.
Declaration
public static Attempt<OperationResult<OperationResultType, TValue>?> Succeed<TValue>(EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, TValue>> | A new attempt instance indicating success. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the entity value. |
Succeed<TValue>(EventMessages, TValue)
Creates a successful operation attempt with a typed value and entity.
Declaration
public static Attempt<OperationResult<OperationResultType, TValue>?> Succeed<TValue>(EventMessages eventMessages, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages produced by the operation. |
| TValue | value | The entity value associated with the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, TValue>> | A new attempt instance indicating success. |
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the entity value. |
Succeed<TStatusType>(TStatusType, EventMessages)
Creates a successful operation attempt with a custom status type.
Declaration
public static Attempt<OperationResult<TStatusType>?> Succeed<TStatusType>(TStatusType statusType, EventMessages eventMessages) where TStatusType : struct
Parameters
| Type | Name | Description |
|---|---|---|
| TStatusType | statusType | The status type indicating the operation result. |
| EventMessages | eventMessages | The event messages produced by the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<TStatusType>> | A new attempt instance indicating success. |
Type Parameters
| Name | Description |
|---|---|
| TStatusType | The type of the status enumeration. |
Succeed<TStatusType, TValue>(TStatusType, EventMessages, TValue)
Creates a successful operation attempt with a custom status type and entity value.
Declaration
public static Attempt<OperationResult<TStatusType, TValue>?> Succeed<TStatusType, TValue>(TStatusType statusType, EventMessages eventMessages, TValue value) where TStatusType : struct
Parameters
| Type | Name | Description |
|---|---|---|
| TStatusType | statusType | The status type indicating the operation result. |
| EventMessages | eventMessages | The event messages produced by the operation. |
| TValue | value | The entity value associated with the operation. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<TStatusType, TValue>> | A new attempt instance indicating success. |
Type Parameters
| Name | Description |
|---|---|
| TStatusType | The type of the status enumeration. |
| TValue | The type of the entity value. |