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 definitionsSymbols/— SVG symbol filesLineStyles/— line style definitionsAreaFills/— area fill definitionsPixmaps/— raster symbol imagesStyleSheets/— 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
sourceIAssetSourceThe asset source used to fetch referenced assets.
cataloguePortrayalCatalogueThe parsed portrayal catalogue.
cataloguePathstringThe 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 conventionalportrayal_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
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
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
itemCatalogItemThe catalogue item whose asset to fetch.
subdirectorystringThe S-100 conventional subdirectory for this item type (e.g.
"ColorProfiles","Symbols").cancellationTokenCancellationTokenA cancellation token.
Returns
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
ruleFileRuleFilecancellationTokenCancellationToken
Returns
FetchRuleAsync(string, CancellationToken)
Fetches a rule file by bare filename from the Rules/ subdirectory.
public Task<Stream> FetchRuleAsync(string fileName, CancellationToken cancellationToken = default)
Parameters
fileNamestringcancellationTokenCancellationToken
Returns
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
sourceIAssetSourceThe asset source containing the portrayal catalogue and assets.
cataloguePathstringThe relative path to the catalogue XML file within the source.
cancellationTokenCancellationTokenA cancellation token.
Returns
ReadAlertCatalogueAsync(CancellationToken)
Reads the catalogue's alert catalogue (AlertCatalog), which sits beside the catalogue XML.
public Task<AlertCatalogue?> ReadAlertCatalogueAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels the read.
Returns
- Task<AlertCatalogue>
The alert catalogue, or null when the catalogue declares none.