Show / Hide Table of Contents

Class LazyResult

Simple struct for tracking a result that holds off generating a string till requested

Inheritance
System.Object
LazyResult
Namespace: Eco.Core.Utils
Assembly: Eco.Core.dll
Syntax
public sealed class LazyResult : ValueType

Constructors

LazyResult(Result)

Constructs LazyResult for stateless Result. Best to be used with reusable cached result defined as static lass member. In that case it has zero-allocations even when resolved with Eco.Core.Utils.LazyResult.Resolve.

Declaration
public LazyResult(Result result)
Parameters
Type Name Description
Result result

LazyResult(Boolean, Object, Func<Object, Result>)

Constructs LazyResult for context aware Result, usually when you need to build a message with link to some context object like a User, or Account, or Deed, or whatever. Ensure that success is always in sync with generated result Success.

Declaration
public LazyResult(bool success, object context, Func<object, Result> resultOrGenerator)
Parameters
Type Name Description
System.Boolean success
System.Object context
System.Func<System.Object, Result> resultOrGenerator
Examples
new LazyResult(false, user, user => Result.FailLoc($"Failed for {user.UILink()}"));

Fields

Value

Declaration
public readonly ResultType Value
Field Value
Type Description
ResultType

Properties

FailedNoMessage

Declaration
public static LazyResult FailedNoMessage { get; }
Property Value
Type Description
LazyResult

Message

Declaration
public LocString Message { get; }
Property Value
Type Description
LocString

NotificationStyle

Declaration
public Nullable<NotificationStyle> NotificationStyle { get; }
Property Value
Type Description
System.Nullable<NotificationStyle>

Succeeded

Declaration
public static LazyResult Succeeded { get; }
Property Value
Type Description
LazyResult

Success

Check if Result is success.

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

Methods

CreateResult()

Creates new Result from LazyResult. Don't use it unless really necessary, prefer to use other functions on LazyResult to check result state and it's message. You still may need this function if you need to pass the Result to another function and use it to merge another results into it.

Declaration
public Result CreateResult()
Returns
Type Description
Result

Operators

Explicit(Result to LazyResult)

Declaration
public static explicit operator LazyResult(Result result)
Parameters
Type Name Description
Result result
Returns
Type Description
LazyResult

Implicit(LazyResult to Boolean)

Declaration
public static implicit operator bool (LazyResult lazyResult)
Parameters
Type Name Description
LazyResult lazyResult
Returns
Type Description
System.Boolean

Extension Methods

PropertyChanges.FirePropertyChanged(Object, String)
PropertyChanges.FirePropertyChanged(Object, String, Object, Object)
PropertyChanges.FirePropertyChanged(Object, MemberChangedBeforeAfterEventArgs)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾