Search Results for

    Show / Hide Table of Contents
    View Source

    Struct Attempt<TResult>

    Represents the result of an operation attempt.

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

    The type of the attempted operation result.

    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

    Success

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

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

    Methods

    View Source

    Fail()

    Creates a failed attempt.

    Declaration
    public static Attempt<TResult> Fail()
    Returns
    Type Description
    Attempt<TResult>

    The failed attempt.

    View Source

    Fail(TResult)

    Creates a failed attempt with a result.

    Declaration
    public static Attempt<TResult> Fail(TResult result)
    Parameters
    Type Name Description
    TResult result

    The result of the attempt.

    Returns
    Type Description
    Attempt<TResult>

    The failed attempt.

    View Source

    Fail(TResult, Exception)

    Creates a failed attempt with a result and an exception.

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

    The result of the attempt.

    Exception exception

    The exception causing the failure of the attempt.

    Returns
    Type Description
    Attempt<TResult>

    The failed attempt.

    View Source

    Fail(Nullable<Exception>)

    Creates a failed attempt with an exception.

    Declaration
    public static Attempt<TResult> Fail(Exception? exception)
    Parameters
    Type Name Description
    System.Nullable<Exception> exception

    The exception causing the failure of the attempt.

    Returns
    Type Description
    Attempt<TResult>

    The failed attempt.

    View Source

    If(Boolean)

    Creates a successful or a failed attempt.

    Declaration
    public static Attempt<TResult> If(bool condition)
    Parameters
    Type Name Description
    System.Boolean condition

    A value indicating whether the attempt is successful.

    Returns
    Type Description
    Attempt<TResult>

    The attempt.

    View Source

    If(Boolean, TResult)

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

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

    View Source

    ResultOr(TResult)

    Gets the attempt result, if successful, else a default value.

    Declaration
    public TResult ResultOr(TResult value)
    Parameters
    Type Name Description
    TResult value
    Returns
    Type Description
    TResult
    View Source

    Succeed()

    Creates a successful attempt.

    Declaration
    public static Attempt<TResult> Succeed()
    Returns
    Type Description
    Attempt<TResult>

    The successful attempt.

    View Source

    Succeed(TResult)

    Creates a successful attempt with a result.

    Declaration
    public static Attempt<TResult> Succeed(TResult result)
    Parameters
    Type Name Description
    TResult result

    The result of the attempt.

    Returns
    Type Description
    Attempt<TResult>

    The successful attempt.

    Operators

    View Source

    Implicit(Attempt<TResult> 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> a)
    Parameters
    Type Name Description
    Attempt<TResult> a
    Returns
    Type Description
    System.Boolean
    • Improve this Doc
    • View Source
    In This Article
    • Properties
      • Exception
      • Result
      • Success
    • Methods
      • Fail()
      • Fail(TResult)
      • Fail(TResult, Exception)
      • Fail(Nullable<Exception>)
      • If(Boolean)
      • If(Boolean, TResult)
      • ResultOr(TResult)
      • Succeed()
      • Succeed(TResult)
    • Operators
      • Implicit(Attempt<TResult> to Boolean)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX