Window Framework for UI Toolkit v2.0.x
GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry Class Referencesealed

Application-owned registry of compiled portable theme extension handlers. More...

Data Structures

class  Lease

Public Member Functions

void Register (IPlayerThemeExtension handler)
 Registers a compiled handler with a unique bounded dotted namespace.
bool TryApply (VisualElement scope, PlayerThemeManifest manifest, out IDisposable lease, out string error)
 Prevalidates all sections, applies in stable order and rolls back leases on failure.
bool TryApplyWithAssets (VisualElement scope, PlayerThemeFolder folder, out IDisposable lease, out string error)
 Applies compiled extensions with validated folder resources, without overloading the data-only manifest API.
bool TrySnapshot (VisualElement scope, PlayerThemeManifest original, Func< string, string, UnityEngine.Texture2D, string > writeImage, out string extensionsJson, out string error)
 Snapshots extension data and declared raster assets through a framework staging writer.
bool TrySnapshot (VisualElement scope, PlayerThemeManifest original, out string extensionsJson, out string error)
 Exports registered effective values while retaining every unknown namespace.
bool Validate (PlayerThemeManifest manifest, out string error)
 Validates all registered sections without applying any changes.

Private Member Functions

bool TryApplyCore (VisualElement scope, PlayerThemeManifest manifest, PlayerThemeFolder folder, out IDisposable lease, out string error)
bool TrySections (PlayerThemeManifest manifest, out GWG.WindowFramework.Theming.Json.JsonObject sections, out string error)
bool TrySnapshotCore (VisualElement scope, PlayerThemeManifest original, Func< string, string, UnityEngine.Texture2D, string > writeImage, out string extensionsJson, out string error)

Static Private Member Functions

static string Diagnostic (Exception exception)

Private Attributes

readonly SortedDictionary< string, IPlayerThemeExtension > _handlers = new SortedDictionary<string, IPlayerThemeExtension>(StringComparer.Ordinal)

Detailed Description

Application-owned registry of compiled portable theme extension handlers.

Never resolves type names from player data. Unknown namespaces are ignored for application and retained during export. Register before importing/applying themes; keep this registry alive as long as its leases. Data-only handlers remain unchanged. Optional IPlayerThemeAssetExtension handlers declare logical raster keys; load with registry-aware folder discovery and apply using the folder overload. Never open unvalidated paths in a handler.

Member Function Documentation

◆ Diagnostic()

string GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.Diagnostic ( Exception exception)
inlinestaticprivate
Here is the caller graph for this function:

◆ Register()

void GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.Register ( IPlayerThemeExtension handler)
inline

Registers a compiled handler with a unique bounded dotted namespace.

Exceptions
ArgumentExceptionNamespace is invalid or already registered.
ArgumentNullExceptionHandler is null.

◆ TryApply()

bool GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.TryApply ( VisualElement scope,
PlayerThemeManifest manifest,
out IDisposable lease,
out string error )
inline

Prevalidates all sections, applies in stable order and rolls back leases on failure.

Parameters
scopeExplicit purchaser UI subtree.
manifestValidated manifest.
leaseNon-null reversible aggregate lease on success.
errorBounded failure diagnostic.
Returns
True only when all registered handlers applied.

Handlers throwing during Apply must undo their own partial mutations. Previously completed handlers are released in reverse order; release failures are reported.

Here is the call graph for this function:

◆ TryApplyCore()

bool GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.TryApplyCore ( VisualElement scope,
PlayerThemeManifest manifest,
PlayerThemeFolder folder,
out IDisposable lease,
out string error )
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryApplyWithAssets()

bool GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.TryApplyWithAssets ( VisualElement scope,
PlayerThemeFolder folder,
out IDisposable lease,
out string error )
inline

Applies compiled extensions with validated folder resources, without overloading the data-only manifest API.

Parameters
scopeExplicit purchaser subtree.
folderLive validated resource owner.
leaseReversible borrowed-resource UI lease; release before folder disposal.
errorBounded failure.
Returns
True when all registered handlers applied transactionally.

Use for image-capable handlers. A distinct name keeps existing TryApply(scope, null, ...) calls unambiguous.

Here is the call graph for this function:

◆ TrySections()

bool GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.TrySections ( PlayerThemeManifest manifest,
out GWG.WindowFramework.Theming.Json.JsonObject sections,
out string error )
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TrySnapshot() [1/2]

bool GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.TrySnapshot ( VisualElement scope,
PlayerThemeManifest original,
Func< string, string, UnityEngine.Texture2D, string > writeImage,
out string extensionsJson,
out string error )
inline

Snapshots extension data and declared raster assets through a framework staging writer.

Parameters
scopePurchaser subtree.
originalSource metadata or null.
writeImageSynchronous namespace/key/texture writer returning relative paths.
extensionsJsonMerged bounded JSON.
errorFailure diagnostic.
Returns
True for a complete validated snapshot.

Intended for transactional exporters, not arbitrary player-controlled writers. Unknown sections remain data only.

Here is the call graph for this function:

◆ TrySnapshot() [2/2]

bool GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.TrySnapshot ( VisualElement scope,
PlayerThemeManifest original,
out string extensionsJson,
out string error )
inline

Exports registered effective values while retaining every unknown namespace.

Parameters
scopePurchaser scope whose effective defaults are exported.
originalSource manifest, or null for a built-in theme.
extensionsJsonMerged standard object JSON on success.
errorValidation failure.
Returns
True only when all snapshots remain valid and bounded.

Unregistered sections are preserved semantically, not byte-for-byte formatting. Nothing returned here is applied automatically or executed.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TrySnapshotCore()

bool GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.TrySnapshotCore ( VisualElement scope,
PlayerThemeManifest original,
Func< string, string, UnityEngine.Texture2D, string > writeImage,
out string extensionsJson,
out string error )
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Validate()

bool GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry.Validate ( PlayerThemeManifest manifest,
out string error )
inline

Validates all registered sections without applying any changes.

Parameters
manifestAlready structurally validated framework manifest.
errorBounded failure diagnostic.
Returns
True when every registered section is accepted.
Here is the call graph for this function:

Field Documentation

◆ _handlers

readonly SortedDictionary<string, IPlayerThemeExtension> GWG.WindowFramework.Theming.PlayerThemeExtensionRegistry._handlers = new SortedDictionary<string, IPlayerThemeExtension>(StringComparer.Ordinal)
private