Class PortrayalCatalogueManager
- Namespace
- EncDotNet.S100.Portrayals
- Assembly
- EncDotNet.S100.Portrayals.dll
Manages portrayal catalogue locations per product specification reference. Caches open PortrayalCatalogueProvider instances so that multiple datasets of the same spec share one catalogue.
public sealed class PortrayalCatalogueManager : IDisposable, ICatalogueProvider<PortrayalCatalogueProvider>
- Inheritance
-
PortrayalCatalogueManager
- Implements
- Inherited Members
Remarks
Each cache slot is keyed by SpecRef, so distinct editions of
the same product (e.g. S-101/1.2.0 versus S-101/2.0.0) are
registered independently. The string-based overloads remain for back-compat:
they delegate via TryNormalize(string?, out string)
and a default SpecVersion, so all string callers share a
single slot per product name.
Properties
RegisteredCatalogues
Returns all registered product specs and their paths, keyed by spec name. When multiple editions of the same spec are registered, the entry returned is unspecified; use RegisteredCataloguesByRef for a deterministic view.
public IReadOnlyDictionary<string, string> RegisteredCatalogues { get; }
Property Value
RegisteredCataloguesByRef
Returns all registered spec references and their paths.
public IReadOnlyDictionary<SpecRef, string> RegisteredCataloguesByRef { get; }
Property Value
Methods
Dispose()
Disposes every PortrayalCatalogueProvider this manager has created and clears the provider and asset caches. Registered paths are kept.
public void Dispose()
GetCatalogueHashAsync(SpecRef, CancellationToken)
Returns a stable lowercase hex SHA-256 content hash of the portrayal
catalogue for spec — the PC XML plus every file it
references — or null when no catalogue is available. Implements
GetCatalogueHashAsync(SpecRef, CancellationToken).
public ValueTask<string?> GetCatalogueHashAsync(SpecRef spec, CancellationToken cancellationToken = default)
Parameters
specSpecRefcancellationTokenCancellationToken
Returns
Remarks
Computed at most once per spec and memoized; the memoized computation is
decoupled from cancellationToken so one caller's
cancellation cannot poison the shared result. A transient failure
(returning null) is not memoized, so a later call retries. The
memo is invalidated by SetPath(SpecRef, string) and
SetSource(SpecRef, IAssetSource); an in-place edit to the
catalogue files under a still-registered path is not observed until one
of those is called again.
GetPath(SpecRef)
Gets the configured catalogue path for the given spec reference, or null if none is set.
public string? GetPath(SpecRef spec)
Parameters
specSpecRef
Returns
GetPath(string)
Gets the configured catalogue path for a product spec, or null if none is set.
public string? GetPath(string productSpec)
Parameters
productSpecstring
Returns
GetProvider(SpecRef)
Gets (or lazily opens) the PortrayalCatalogueProvider for the given spec reference.
public PortrayalCatalogueProvider GetProvider(SpecRef spec)
Parameters
specSpecRef
Returns
Remarks
Concurrent first-misses for the same spec collapse to a single underlying open via Lazy<T> with ExecutionAndPublication, so the IAssetSource behind the provider is constructed at most once per spec slot. Path/source presence is validated before the lazy is added to the cache; if a registered path is missing on disk, the slot is never created, leaving callers free to fix the configuration and try again without poisoning the slot with a faulted Lazy.
Exceptions
- InvalidOperationException
No catalogue path registered for the spec.
- DirectoryNotFoundException
The registered path does not exist.
GetProvider(string)
Gets (or lazily opens) the PortrayalCatalogueProvider for the given product spec.
public PortrayalCatalogueProvider GetProvider(string productSpec)
Parameters
productSpecstring
Returns
HasCatalogue(SpecRef)
Returns true if a catalogue is available for the given spec reference.
public bool HasCatalogue(SpecRef spec)
Parameters
specSpecRef
Returns
HasCatalogue(string)
Returns true if a catalogue is available for the given product spec (either via a registered path or a directly registered source).
public bool HasCatalogue(string productSpec)
Parameters
productSpecstring
Returns
SetPath(SpecRef, string)
Registers (or updates) the file-system path for the given spec reference's portrayal catalogue. Evicts any previously cached provider for that spec.
public void SetPath(SpecRef spec, string cataloguePath)
Parameters
SetPath(string, string)
Registers (or updates) the file-system path for a product spec's portrayal catalogue. Evicts any previously cached provider for that spec.
public void SetPath(string productSpec, string cataloguePath)
Parameters
productSpecstringThe product specification identifier (e.g. "S-101", "S-102").
cataloguePathstringAbsolute path to the catalogue folder on disk.
SetSource(SpecRef, IAssetSource)
Registers an IAssetSource directly for the given spec reference's portrayal catalogue. The source is opened immediately and the resulting provider is cached. Evicts any previously cached provider or path.
public void SetSource(SpecRef spec, IAssetSource source)
Parameters
specSpecRefsourceIAssetSource
SetSource(string, IAssetSource)
Registers an IAssetSource directly for a product spec's portrayal catalogue. The source is opened immediately and the resulting provider is cached. Evicts any previously cached provider or path for that spec.
public void SetSource(string productSpec, IAssetSource source)
Parameters
productSpecstringsourceIAssetSource