Search Results for

    Class LayerResponse

    The result of a fallible operation with no value: either success, or failure with one or more Errors (STYLE_GUIDE §3). Return an Error or a list of them directly; implicit conversions build the response.

    Inheritance
    object
    LayerResponse
    LayerResponse<TResult>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: ZhEaIsNsAaBn.Utilities
    Assembly: ZhEaIsNsAaBn.LayerResponse.dll
    Syntax
    public class LayerResponse

    Constructors

    LayerResponse(bool, List<Error>?)

    Creates a response from a list of errors.

    Declaration
    protected LayerResponse(bool isSuccess, List<Error>? errors = null)
    Parameters
    Type Name Description
    bool isSuccess

    Whether the operation succeeded.

    List<Error> errors

    Empty or null on success; at least one real error on failure.

    Exceptions
    Type Condition
    InvalidOperationException

    Success with errors, or failure with no real error.

    LayerResponse(bool, Error)

    Creates a response from one error.

    Declaration
    protected LayerResponse(bool isSuccess, Error error)
    Parameters
    Type Name Description
    bool isSuccess

    Whether the operation succeeded.

    Error error

    None on success; a real error on failure.

    Exceptions
    Type Condition
    InvalidOperationException

    Success with a real error, or failure with None.

    Properties

    Errors

    The errors. Empty on success.

    Declaration
    public List<Error> Errors { get; }
    Property Value
    Type Description
    List<Error>

    IsFailure

    Whether the operation failed.

    Declaration
    public bool IsFailure { get; }
    Property Value
    Type Description
    bool

    IsSuccess

    Whether the operation succeeded.

    Declaration
    public bool IsSuccess { get; }
    Property Value
    Type Description
    bool

    Methods

    Failure(List<Error>)

    Creates a failed response.

    Declaration
    public static LayerResponse Failure(List<Error> errors)
    Parameters
    Type Name Description
    List<Error> errors

    The errors; at least one.

    Returns
    Type Description
    LayerResponse

    A failed response.

    Failure(Error)

    Creates a failed response.

    Declaration
    public static LayerResponse Failure(Error error)
    Parameters
    Type Name Description
    Error error

    The error.

    Returns
    Type Description
    LayerResponse

    A failed response.

    Success()

    Creates a successful response.

    Declaration
    public static LayerResponse Success()
    Returns
    Type Description
    LayerResponse

    A successful response.

    ToLayerResponse<TResult>(LayerResponse)

    Copies the outcome into a LayerResponse<TResult> with no value.

    Declaration
    public static LayerResponse<TResult> ToLayerResponse<TResult>(LayerResponse result)
    Parameters
    Type Name Description
    LayerResponse result

    The response to copy.

    Returns
    Type Description
    LayerResponse<TResult>

    Success, or failure with the same errors.

    Type Parameters
    Name Description
    TResult

    The value type of the new response.

    Operators

    implicit operator LayerResponse(List<Error>)

    Wraps errors as a failed response.

    Declaration
    public static implicit operator LayerResponse(List<Error> errors)
    Parameters
    Type Name Description
    List<Error> errors

    The errors; at least one.

    Returns
    Type Description
    LayerResponse

    implicit operator LayerResponse(Error)

    Wraps an error as a failed response.

    Declaration
    public static implicit operator LayerResponse(Error error)
    Parameters
    Type Name Description
    Error error

    The error.

    Returns
    Type Description
    LayerResponse

    implicit operator List<Error>(LayerResponse)

    Gets the errors.

    Declaration
    public static implicit operator List<Error>(LayerResponse response)
    Parameters
    Type Name Description
    LayerResponse response

    The response.

    Returns
    Type Description
    List<Error>

    implicit operator Error(LayerResponse)

    Gets the first error, or None on success.

    Declaration
    public static implicit operator Error(LayerResponse response)
    Parameters
    Type Name Description
    LayerResponse response

    The response.

    Returns
    Type Description
    Error
    In this article
    Back to top Generated by DocFX