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
    [Serializable]
    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
    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
    bool

    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(Exception?)

    Creates a failed attempt with an exception.

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

    The exception causing the failure of the attempt.

    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

    If(bool)

    Creates a successful or a failed attempt.

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

    A value indicating whether the attempt is successful.

    Returns
    Type Description
    Attempt<TResult>

    The attempt.

    View Source

    If(bool, 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
    bool 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 operator bool(Attempt<TResult>)

    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
    bool
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX