logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class CompiledHudBinding

    A HUD binding that has been resolved against real types and is ready to be read every tick.

    Inheritance
    object
    CompiledHudBinding
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.GameUi.Application.Binding
    Assembly: Serenity.GameUi.Application.dll
    Syntax
    public sealed class CompiledHudBinding
    Remarks

    An invalid binding is a first-class outcome rather than an exception: a HUD authored by reflection will eventually point at a renamed member, and it must show its fallback text and report why instead of throwing once per frame.

    Properties

    Error

    Why the chain could not be resolved; empty when it is valid.

    Declaration
    public string Error { get; }
    Property Value
    Type Description
    string

    FallbackText

    What to display when a read produces no value.

    Declaration
    public string FallbackText { get; }
    Property Value
    Type Description
    string

    IsValid

    Whether the chain resolved and can be read.

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

    ResultType

    The static type of the final step, or null when the chain is invalid.

    Declaration
    public Type ResultType { get; }
    Property Value
    Type Description
    Type

    ValueKind

    How the final step's type classifies for representation purposes.

    Declaration
    public HudValueKind ValueKind { get; }
    Property Value
    Type Description
    HudValueKind

    ValueTransform

    How the read value is reshaped before TryRead(out object) hands it out.

    Declaration
    public HudValueTransform ValueTransform { get; }
    Property Value
    Type Description
    HudValueTransform

    Methods

    Constant(object, HudValueTransform)

    Creates a binding that always reads the same value.

    Declaration
    public static CompiledHudBinding Constant(object value, HudValueTransform valueTransform = null)
    Parameters
    Type Name Description
    object value

    The value every read returns.

    HudValueTransform valueTransform

    How the value is reshaped before it is handed out. The preview runs the same transform the game would, since its whole premise is exercising exactly the runtime's own drawing code.

    Returns
    Type Description
    CompiledHudBinding

    A readable binding over the constant.

    Remarks

    What lets the editor preview drive the real renderers with sample data: no service needs to be running, and the preview therefore exercises exactly the same drawing code as the game rather than a parallel approximation of it. A chain with no steps yields its source directly, so this needs no special case in TryRead(out object).

    Invalid(string, string)

    Creates a binding that could not be resolved.

    Declaration
    public static CompiledHudBinding Invalid(string error, string fallbackText)
    Parameters
    Type Name Description
    string error

    Why it could not be resolved.

    string fallbackText

    What the element should display instead.

    Returns
    Type Description
    CompiledHudBinding

    Supports(HudRepresentationKind)

    Whether the given representation may render this binding's value.

    Declaration
    public bool Supports(HudRepresentationKind representation)
    Parameters
    Type Name Description
    HudRepresentationKind representation

    The representation to check.

    Returns
    Type Description
    bool

    TryRead(out object)

    Walks the chain and produces the current value.

    Declaration
    public bool TryRead(out object value)
    Parameters
    Type Name Description
    object value

    The value read, when the whole chain produced one.

    Returns
    Type Description
    bool

    False when the binding is invalid, the source is not available yet, or any step yielded nothing.

    Remarks

    When ValueTransform is active and the value converts to a number, the transformed number is what comes out — every consumer of a read value, including TryReadNumber(out double) and the icon-set representation's text-based matching, sees the same reshaped result, because this is the one place the transform is applied. A value that does not convert to a number (text, a bool, an enum) passes through untouched: there is nothing numeric to reshape.

    TryReadNumber(out double)

    Reads the value as a number, for the numeric and time representations.

    Declaration
    public bool TryReadNumber(out double number)
    Parameters
    Type Name Description
    double number

    The numeric value, when one could be read.

    Returns
    Type Description
    bool

    True when the chain produced a number.

    TryReadText(out string)

    Reads the value as display text, formatted with the invariant culture.

    Declaration
    public bool TryReadText(out string text)
    Parameters
    Type Name Description
    string text

    The value as invariant text, when one could be read.

    Returns
    Type Description
    bool

    False when the binding is invalid, the read produced nothing, or the value is null.

    Remarks

    Numbers must render the same on every machine: an icon-set entry authored as "10.5" has to match the bound value under a comma-decimal locale too, so culture-sensitive ToString() is not an option.

    In this article
    © 2026 Serenity. All Rights Reserved