Search Results for

    Show / Hide Table of Contents
    View Source

    Struct Attempt<TResult, TStatus>

    Represents the result of an operation attempt.

    Namespace: Umbraco.Cms.Core
    Assembly: Umbraco.Core.dll
    Syntax
    public struct Attempt<TResult, TStatus>
    Type Parameters
    Name Description
    TResult

    The type of the attempted operation result.

    TStatus

    The type of the attempted operation status.

    Properties

    View Source

    Exception

    Gets the exception associated with an unsuccessful attempt.

    Declaration
    public readonly Exception? Exception { get; }
    Property Value
    Type Description
    System.Nullable<Exception>
    View Source

    Result

    Gets the attempt result.

    Declaration
    public readonly TResult Result { get; }
    Property Value
    Type Description
    TResult
    View Source

    Status

    Gets the attempt status.

    Declaration
    public readonly TStatus Status { get; }
    Property Value
    Type Description
    TStatus
    View Source

    Success

    Gets a value indicating whether this Attempt<TResult, TStatus> was successful.

    Declaration
    public readonly bool Success { get; }
    Property Value
    Type Description
    System.Boolean

    Methods

    View Source

    Fail(TStatus)

    Creates a failed attempt.

    Declaration
    public static Attempt<TResult, TStatus> Fail(TStatus status)
    Parameters
    Type Name Description
    TStatus status

    The status of the attempt.

    Returns
    Type Description
    Attempt<TResult, TStatus>

    The failed attempt.

    View Source

    Fail(TStatus, TResult)

    Creates a failed attempt with a result.

    Declaration
    public static Attempt<TResult, TStatus> Fail(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.

    View Source

    Fail(TStatus, TResult, Exception)

    Creates a failed attempt with a result and an exception.

    Declaration
    public static Attempt<TResult, TStatus> Fail(TStatus status, TResult result, Exception exception)
    Parameters
    Type Name Description
    TStatus status

    The status of the attempt.

    TResult result

    The result of the attempt.

    Exception exception

    The exception causing the failure of the attempt.

    Returns
    Type Description
    Attempt<TResult, TStatus>

    The failed attempt.

    View Source

    Fail(TStatus, Exception)

    Creates a failed attempt with an exception.

    Declaration
    public static Attempt<TResult, TStatus> Fail(TStatus status, Exception exception)
    Parameters
    Type Name Description
    TStatus status

    The status of the attempt.

    Exception exception

    The exception causing the failure of the attempt.

    Returns
    Type Description
    Attempt<TResult, TStatus>

    The failed attempt.

    View Source

    If(Boolean, TStatus, TStatus)

    Creates a successful or a failed attempt.

    Declaration
    public static Attempt<TResult, TStatus> If(bool condition, TStatus succStatus, TStatus failStatus)
    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.

    Returns
    Type Description
    Attempt<TResult, TStatus>

    The attempt.

    View Source

    If(Boolean, TStatus, TStatus, TResult)

    Creates a successful or a failed attempt, with a result.

    Declaration
    public static Attempt<TResult, TStatus> If(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.

    View Source

    Succeed(TStatus)

    Creates a successful attempt.

    Declaration
    public static Attempt<TResult, TStatus> Succeed(TStatus status)
    Parameters
    Type Name Description
    TStatus status

    The status of the attempt.

    Returns
    Type Description
    Attempt<TResult, TStatus>

    The successful attempt.

    View Source

    Succeed(TStatus, TResult)

    Creates a successful attempt with a result.

    Declaration
    public static Attempt<TResult, TStatus> Succeed(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.

    Operators

    View Source

    Implicit(Attempt<TResult, TStatus> to Boolean)

    Implicitly operator to check if the attempt was successful without having to access the 'success' property

    Declaration
    public static implicit operator bool (Attempt<TResult, TStatus> a)
    Parameters
    Type Name Description
    Attempt<TResult, TStatus> a
    Returns
    Type Description
    System.Boolean
    • Improve this Doc
    • View Source
    In This Article
    • Properties
      • Exception
      • Result
      • Status
      • Success
    • Methods
      • Fail(TStatus)
      • Fail(TStatus, TResult)
      • Fail(TStatus, TResult, Exception)
      • Fail(TStatus, Exception)
      • If(Boolean, TStatus, TStatus)
      • If(Boolean, TStatus, TStatus, TResult)
      • Succeed(TStatus)
      • Succeed(TStatus, TResult)
    • Operators
      • Implicit(Attempt<TResult, TStatus> to Boolean)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX