Table of Contents

Class PortrayalCatalogueProvider

Namespace
EncDotNet.S100.Portrayals
Assembly
EncDotNet.S100.Portrayals.dll

A portrayal catalogue provider backed by an IAssetSource.

public sealed class PortrayalCatalogueProvider : IDisposable
Inheritance
PortrayalCatalogueProvider
Implements
Inherited Members

Remarks

S-100 Ed 5.2 portrayal catalogues use a well-known directory layout where the <fileName> in the catalogue XML contains only the bare filename. Assets are stored in conventional subdirectories relative to the catalogue root:

  • Rules/ — rule files (Lua, XSLT)
  • ColorProfiles/ — colour palette definitions
  • Symbols/ — SVG symbol files
  • LineStyles/ — line style definitions
  • AreaFills/ — area fill definitions
  • Pixmaps/ — raster symbol images
  • StyleSheets/ — XSLT/CSS stylesheets

This provider prepends the conventional subdirectory when fetching assets.

Constructors

PortrayalCatalogueProvider(IAssetSource, PortrayalCatalogue, string)

Initializes a new instance of PortrayalCatalogueProvider with the given source and catalogue.

public PortrayalCatalogueProvider(IAssetSource source, PortrayalCatalogue catalogue, string cataloguePath = "portrayal_catalogue.xml")

Parameters

source IAssetSource

The asset source used to fetch referenced assets.

catalogue PortrayalCatalogue

The parsed portrayal catalogue.

cataloguePath string

The relative path of the catalogue XML within source, retained so the raw catalogue bytes can be re-read for content hashing. Defaults to the S-100 conventional portrayal_catalogue.xml.

Properties

AssetCache

The decoded-asset cache that backs every catalogue wrapper (compiled XSLT, SVG symbols, line styles, area fills, palettes, Lua scripts, Lua source strings).

public IPortrayalAssetCache AssetCache { get; }

Property Value

IPortrayalAssetCache

Remarks

Defaults to a fresh per-provider PortrayalAssetCache the first time it is read. PortrayalCatalogueManager stamps a shared per-SpecRef cache here (via AttachAssetCache(IPortrayalAssetCache)) before handing the provider out, so two catalogue wrappers for the same spec share asset storage (asset-caching audit §6 PR-3).

Direct callers of OpenAsync(IAssetSource, string, CancellationToken) — primarily tests — get an isolated per-provider cache, which preserves the contract verified by LuaSourceCacheTests.S101_GetLuaSource_independent_caches_per_catalogue_instance.

Catalogue

Gets the parsed portrayal catalogue metadata.

public PortrayalCatalogue Catalogue { get; }

Property Value

PortrayalCatalogue

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

FetchAssetAsync(CatalogItem, string, CancellationToken)

Fetches the content of a portrayal asset referenced by a catalogue item, looking in the given conventional subdirectory.

public Task<Stream> FetchAssetAsync(CatalogItem item, string subdirectory, CancellationToken cancellationToken = default)

Parameters

item CatalogItem

The catalogue item whose asset to fetch.

subdirectory string

The S-100 conventional subdirectory for this item type (e.g. "ColorProfiles", "Symbols").

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Stream>

FetchAssetAsync(RuleFile, CancellationToken)

Fetches the content of a portrayal asset referenced by a rule file. Rule files are resolved under the Rules/ subdirectory.

public Task<Stream> FetchAssetAsync(RuleFile ruleFile, CancellationToken cancellationToken = default)

Parameters

ruleFile RuleFile
cancellationToken CancellationToken

Returns

Task<Stream>

FetchRuleAsync(string, CancellationToken)

Fetches a rule file by bare filename from the Rules/ subdirectory.

public Task<Stream> FetchRuleAsync(string fileName, CancellationToken cancellationToken = default)

Parameters

fileName string
cancellationToken CancellationToken

Returns

Task<Stream>

OpenAsync(IAssetSource, string, CancellationToken)

Opens a PortrayalCatalogueProvider by reading the catalogue from the given source.

public static Task<PortrayalCatalogueProvider> OpenAsync(IAssetSource source, string cataloguePath = "portrayal_catalogue.xml", CancellationToken cancellationToken = default)

Parameters

source IAssetSource

The asset source containing the portrayal catalogue and assets.

cataloguePath string

The relative path to the catalogue XML file within the source.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<PortrayalCatalogueProvider>

ReadAlertCatalogueAsync(CancellationToken)

Reads the catalogue's alert catalogue (AlertCatalog), which sits beside the catalogue XML.

public Task<AlertCatalogue?> ReadAlertCatalogueAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels the read.

Returns

Task<AlertCatalogue>

The alert catalogue, or null when the catalogue declares none.