AnkiIO 1.0.2
Build, validate, import, and export Anki-compatible decks from .NET
Loading...
Searching...
No Matches
AnkiIO.AnkiCompatibilityRegistry Class Referencesealed

Registers version adapters in precedence order and resolves verified capabilities for an Anki version. More...

Public Member Functions

 AnkiCompatibilityRegistry ()
 Initializes an empty compatibility registry.
AnkiCompatibilityRegistry Add (IAnkiVersionAdapter adapter)
 Registers an adapter at the end of the resolution precedence.
IAnkiVersionAdapter Resolve (Version version)
 Returns the highest-precedence registered adapter supporting an Anki application version.

Static Public Member Functions

static AnkiCompatibilityRegistry CreateDefault ()
 Creates a new registry populated with AnkiIO's built-in, evidence-backed adapters.

Detailed Description

Registers version adapters in precedence order and resolves verified capabilities for an Anki version.

Resolution returns the first adapter whose IAnkiVersionAdapter.Supports method succeeds. Register narrow or application-specific adapters before broad fallbacks. CreateDefault places built-in adapters first, so adapters appended to that result do not override a built-in match; create an empty registry to choose custom-first precedence explicitly.

Registries are mutable configuration objects and are not safe for concurrent registration and resolution. Adapters may overlap and may be added more than once; ordering, rather than deduplication, defines the outcome. Each default registry and each built-in adapter instance is independent, while its capability sets remain immutable.

var installation = AnkiInstallationDetector.Detect();
if (installation is not null)
{
var capabilities = AnkiCompatibilityRegistry.CreateDefault().Resolve(installation.Version);
Console.WriteLine($"{capabilities.Name}: scheduler {capabilities.SchedulerVersion}");
}
AnkiCompatibilityRegistry()
Initializes an empty compatibility registry.
Discovers a local Anki executable and reports conservative profile-presence metadata.
static ? AnkiInstallation Detect()
Locates the first existing Anki executable using overrides and platform conventions.

Definition at line 25 of file AnkiCompatibilityRegistry.cs.

Constructor & Destructor Documentation

◆ AnkiCompatibilityRegistry()

AnkiIO.AnkiCompatibilityRegistry.AnkiCompatibilityRegistry ( )
inline

Initializes an empty compatibility registry.

Add adapters from highest to lowest precedence. Use CreateDefault when built-in, evidence-backed adapters should be registered automatically.

Definition at line 34 of file AnkiCompatibilityRegistry.cs.

Member Function Documentation

◆ Add()

AnkiCompatibilityRegistry AnkiIO.AnkiCompatibilityRegistry.Add ( IAnkiVersionAdapter adapter)
inline

Registers an adapter at the end of the resolution precedence.

Parameters
adapterThe compatibility adapter to register.
Returns
This registry, enabling fluent ordered registration.

Duplicate instances and overlapping ranges are permitted. If several adapters support a version, Resolve returns the one registered earliest.

Exceptions
ArgumentNullExceptionadapter is null.

Definition at line 46 of file AnkiCompatibilityRegistry.cs.

◆ CreateDefault()

AnkiCompatibilityRegistry AnkiIO.AnkiCompatibilityRegistry.CreateDefault ( )
inlinestatic

Creates a new registry populated with AnkiIO's built-in, evidence-backed adapters.

Returns
A mutable registry containing a new Anki2605VersionAdapter.

Each call returns an independent registry. Additions to one result do not affect later results. Appended adapters have lower precedence than the built-ins already present.

Definition at line 74 of file AnkiCompatibilityRegistry.cs.

◆ Resolve()

IAnkiVersionAdapter AnkiIO.AnkiCompatibilityRegistry.Resolve ( Version version)
inline

Returns the highest-precedence registered adapter supporting an Anki application version.

Parameters
versionThe parsed Anki application version to resolve.
Returns
The first registered adapter that reports compatibility with version .

This is a metadata lookup only. It neither detects Anki nor opens a package or collection. An unsupported result is explicit rather than silently selecting the nearest release family.

Exceptions
ArgumentNullExceptionversion is null.
NotSupportedExceptionNo registered adapter supports version .

Definition at line 62 of file AnkiCompatibilityRegistry.cs.


The documentation for this class was generated from the following file: