Class ReasonTagExtensions

Namespace
REslava.Result
Assembly
REslava.Result.dll

Extension methods for typed tag access on IReason using TagKey<T>.

public static class ReasonTagExtensions
Inheritance
ReasonTagExtensions
Inherited Members

Methods

Has<T>(IReason, TagKey<T>)

Returns true if the reason's Tags contains the given key with a value castable to T.

public static bool Has<T>(this IReason reason, TagKey<T> key)

Parameters

reason IReason
key TagKey<T>

Returns

bool

Type Parameters

T

TryGet<T>(IReason, TagKey<T>, out T?)

Tries to get the value of a typed tag from the reason's Tags dictionary. Returns false if the key is not present or the value cannot be cast to T.

public static bool TryGet<T>(this IReason reason, TagKey<T> key, out T? value)

Parameters

reason IReason
key TagKey<T>
value T

Returns

bool

Type Parameters

T

Examples

if (error.TryGet(DomainTags.Entity, out var entity))
    logger.LogError("Entity {Entity} failed", entity);