Table of Contents

Class S101PortrayalCatalogue

Namespace
EncDotNet.S100.Datasets.S101
Assembly
EncDotNet.S100.Datasets.S101.dll

S-101 portrayal catalogue implementing IVectorPortrayalCatalogue. Loads and compiles XSLT rules, caches Lua scripts, and resolves symbols, line styles, and area fills from a PortrayalCatalogueProvider.

public sealed class S101PortrayalCatalogue : IVectorPortrayalCatalogue, IPortrayalCatalogue, IXsltRuleSource, ILuaRuleSource, IPortrayalAssetSource
Inheritance
S101PortrayalCatalogue
Implements
Inherited Members

Constructors

S101PortrayalCatalogue(PortrayalCatalogueProvider, ILuaEngine?)

Creates an S-101 portrayal catalogue backed by the given provider. Decoded assets (compiled XSLT, symbols, line styles, area fills, palettes, Lua sources) are cached on the provider's AssetCache.

public S101PortrayalCatalogue(PortrayalCatalogueProvider provider, ILuaEngine? luaEngine = null)

Parameters

provider PortrayalCatalogueProvider

The portrayal catalogue provider that supplies rule files and assets.

luaEngine ILuaEngine

The Lua engine used to run Lua portrayal rules, or null when only XSLT rules will be executed.

Exceptions

ArgumentNullException

provider is null.

Properties

ActivePalette

The currently active colour palette.

public ColorPalette ActivePalette { get; }

Property Value

ColorPalette

Remarks

Implementations start at the empty Default until the first SwitchPaletteAsync(PaletteType, CancellationToken) call loads the catalogue's colour profile; never null.

CatalogueRef

The identity of the underlying portrayal catalogue XML, when available.

public CatalogueRef? CatalogueRef { get; }

Property Value

CatalogueRef?

ContextParameters

The context parameters declared by the S-101 portrayal catalogue (S-100 Part 9A), projected onto the Core LuaContextParameter type for the generic Lua executor.

public IReadOnlyList<LuaContextParameter> ContextParameters { get; }

Property Value

IReadOnlyList<LuaContextParameter>

DisplayModes

Tracks the active S-100 Part 9 display-mode id for the catalogue. When the controller's active id changes the catalogue is responsible for resolving the corresponding viewing-group membership and pushing it into ViewingGroups via SetActiveModeMembership(IReadOnlySet<int>?).

public DisplayModeController DisplayModes { get; }

Property Value

DisplayModeController

DisplayPlanes

Controls which S-100 Part 9 §11.6 display planes are visible.

public DisplayPlaneController DisplayPlanes { get; }

Property Value

DisplayPlaneController

Edition

The edition of the underlying portrayal catalogue (matches PortrayalCatalogue.Version).

public string Edition { get; }

Property Value

string

Rules

All portrayal rules defined in the catalogue, ordered by ExecutionOrder.

public IReadOnlyList<PortrayalRule> Rules { get; }

Property Value

IReadOnlyList<PortrayalRule>

Remarks

Built lazily from the catalogue's rule files, in declaration order. A rule's type (XSLT or Lua) is taken from its file extension, and its target feature type is inferred from the rule name with any trailing digits removed; top-level and template rules apply to every feature.

Spec

The product specification (name + edition) this catalogue targets.

public SpecRef Spec { get; }

Property Value

SpecRef

ViewingGroups

Controls which viewing groups are currently visible.

public ViewingGroupController ViewingGroups { get; }

Property Value

ViewingGroupController

Methods

GetAreaFillAsync(string, CancellationToken)

Resolves an area fill by name from the catalogue resources.

public ValueTask<AreaFill> GetAreaFillAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string
cancellationToken CancellationToken

Returns

ValueTask<AreaFill>

GetCompiledRuleAsync(string, CancellationToken)

Returns the compiled XSLT transform for the named rule.

public ValueTask<XslCompiledTransform> GetCompiledRuleAsync(string ruleName, CancellationToken cancellationToken = default)

Parameters

ruleName string
cancellationToken CancellationToken

Returns

ValueTask<XslCompiledTransform>

GetLineStyleAsync(string, CancellationToken)

Resolves a line style by name from the catalogue resources.

public ValueTask<LineStyle> GetLineStyleAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string
cancellationToken CancellationToken

Returns

ValueTask<LineStyle>

GetLuaSourceAsync(string, CancellationToken)

Returns the raw Lua source for the given bare filename inside the portrayal catalogue's Rules/ directory (e.g. "main.lua", "S100Scripting.lua"), caching the decoded string so subsequent reads do not re-open the underlying IAssetSource.

public ValueTask<string?> GetLuaSourceAsync(string fileName, CancellationToken cancellationToken = default)

Parameters

fileName string
cancellationToken CancellationToken

Returns

ValueTask<string>

Remarks

Returns null (and caches null) if the file cannot be fetched, so the MoonSharp module loader's "missing module → return null" contract is preserved without retrying failed lookups on every require() call.

This caches only the immutable string source. The compiled Lua Script instance is intentionally constructed per execution to preserve sandbox isolation (S-100 Part 9A).

GetLuaSourceNamesAsync(CancellationToken)

Returns every Lua rule file declared in the portrayal catalogue manifest (filtered to .lua extension), e.g. main.lua, S100Scripting.lua.

public ValueTask<IReadOnlyList<string>> GetLuaSourceNamesAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<IReadOnlyList<string>>

GetSymbolAsync(string, CancellationToken)

Resolves an SVG symbol by name from the catalogue resources.

public ValueTask<SvgSymbol> GetSymbolAsync(string symbolName, CancellationToken cancellationToken = default)

Parameters

symbolName string
cancellationToken CancellationToken

Returns

ValueTask<SvgSymbol>

SwitchPaletteAsync(PaletteType, CancellationToken)

Switches the active colour palette to type.

public ValueTask SwitchPaletteAsync(PaletteType type, CancellationToken cancellationToken = default)

Parameters

type PaletteType

The palette mood (Day, Dusk, or Night).

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask

Remarks

Asynchronous because catalogues that load palettes lazily from IAssetSource may need to fetch the colour profile XML on first access. Cached implementations complete synchronously through the ValueTask fast path. When the catalogue has no palette for type, implementations keep a usable palette active (the current one, or Day) rather than failing. Coverage catalogues also use this call to pre-load the assets their synchronous resolve methods need, so it must be awaited before those are called (see SwitchPaletteAsync(PaletteType, CancellationToken)).