Game.UI.Widgets.FieldBuilder
Assembly:
Game (Game.dll)
Namespace: Game.UI.Widgets
Type:
delegate
Base:
System.MulticastDelegate
Summary:
A delegate type used by the UI system to create or "build" an IWidget instance for a given IValueAccessor. Typical usage is providing a small factory function that knows how to construct an appropriate widget (label, input, toggle, etc.) for the provided accessor so the UI framework can render or edit the underlying value.
Fields
- (none)
This delegate type does not declare any explicit fields in user code. Like all delegates, the compiler generates behind-the-scenes fields to store the target and method, but they are not accessible as part of the public API.
Properties
- (none)
No custom properties are defined on this delegate type.
Constructors
public FieldBuilder(object object, System.IntPtr method)
Compiler-generated delegate constructor. You rarely call this directly in C#; instead you create instances using a method group, lambda expression, or anonymous method (e.g.,FieldBuilder fb = accessor => ...;
).
Methods
-
public IWidget Invoke(IValueAccessor accessor)
Synchronous invoke method. Calls the underlying method to create and return an IWidget for the supplied accessor. -
public System.IAsyncResult BeginInvoke(IValueAccessor accessor, System.AsyncCallback callback, object @object)
public IWidget EndInvoke(System.IAsyncResult result)
Asynchronous begin/end invoke pair generated by the runtime for delegates (rarely used in modern C# code; included for completeness).
Usage Example
// Example assumes IWidget and IValueAccessor exist in the project's UI/Reflection APIs.
// Create a FieldBuilder via a lambda that returns an IWidget implementation.
FieldBuilder textFieldBuilder = accessor =>
{
// Example: create a simple LabelWidget that reads a string from the accessor.
// LabelWidget is a placeholder for whatever IWidget implementation you have.
string text = accessor.GetValue()?.ToString() ?? string.Empty;
return new LabelWidget(text); // LabelWidget : IWidget
};
// Using the builder to create a widget for a given accessor:
IValueAccessor someAccessor = /* obtain accessor from the UI system */;
IWidget widget = textFieldBuilder(someAccessor);
// The framework can store 'textFieldBuilder' and invoke it whenever a widget
// for that accessor (or field type) is needed.
Additional notes: - IValueAccessor (from Game.Reflection) typically gives read/write access to the underlying value (GetValue, SetValue, metadata). - Implementations of FieldBuilder are commonly registered with UI systems or field factories so that fields of specific types or with specific attributes get consistent widget representations.