Class LazyResult
Simple struct for tracking a result that holds off generating a string till requested
Inheritance
System.Object
LazyResult
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
Properties
FailedNoMessage
Declaration
public static LazyResult FailedNoMessage { get; }
Property Value
Message
Declaration
public LocString Message { get; }
Property Value
NotificationStyle
Declaration
public Nullable<NotificationStyle> NotificationStyle { get; }
Property Value
Succeeded
Declaration
public static LazyResult Succeeded { get; }
Property Value
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
Operators
Explicit(Result to LazyResult)
Declaration
public static explicit operator LazyResult(Result result)
Parameters
Type |
Name |
Description |
Result |
result |
|
Returns
Implicit(LazyResult to Boolean)
Declaration
public static implicit operator bool (LazyResult lazyResult)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Extension Methods