Table of Contents

Class FileSystemAssetRepository

Namespace
Tudormobile.IronLedgerLib
Assembly
Tudormobile.IronLedgerLib.dll

An IAssetRepository implementation that stores each asset as a JSON file and an optional Markdown notes file under a configurable root directory.

public class FileSystemAssetRepository : IAssetRepository
Inheritance
FileSystemAssetRepository
Implements
Inherited Members

Remarks

Each asset is stored in its own subdirectory named after Id:

{dataPath}/
  {assetId}/
    asset.json
    notes.md

Constructors

FileSystemAssetRepository(string, IIronLedgerSerializer)

Initializes a new instance of the FileSystemAssetRepository class.

public FileSystemAssetRepository(string dataPath, IIronLedgerSerializer serializer)

Parameters

dataPath string

The root directory under which asset folders are stored.

serializer IIronLedgerSerializer

The serializer used to read and write asset JSON files.

Methods

DeleteAsync(string, CancellationToken)

Deletes the asset record and its associated notes for the given identifier.

public Task DeleteAsync(string assetId, CancellationToken cancellationToken = default)

Parameters

assetId string

The unique asset identifier to delete.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

ExistsAsync(AssetRecord, CancellationToken)

Determine if a record currently exists in the repository.

public Task<bool> ExistsAsync(AssetRecord asset, CancellationToken cancellationToken = default)

Parameters

asset AssetRecord

The asset record to check.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<bool>

GetAllAsync(CancellationToken)

Retrieves all stored asset records.

public Task<IReadOnlyList<AssetRecord>> GetAllAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<IReadOnlyList<AssetRecord>>

A read-only list of all stored AssetRecord instances.

GetAllIdentifiersAsync(CancellationToken)

Asynchronously retrieves all available asset identifiers.

public Task<IReadOnlyList<string>> GetAllIdentifiersAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A cancellation token that can be used to cancel the operation.

Returns

Task<IReadOnlyList<string>>

A read-only list of strings containing all identifiers. The list will be empty if no identifiers are available.

GetAsync(string, CancellationToken)

Retrieves a single asset record by its identifier.

public Task<AssetRecord?> GetAsync(string assetId, CancellationToken cancellationToken = default)

Parameters

assetId string

The unique asset identifier (see Id).

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<AssetRecord>

The AssetRecord if found; otherwise null.

GetNotesAsync(string, CancellationToken)

Retrieves the markdown notes associated with an asset.

public Task<string> GetNotesAsync(string assetId, CancellationToken cancellationToken = default)

Parameters

assetId string

The unique asset identifier.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<string>

The markdown text, or Empty if no notes exist.

SaveAsync(AssetRecord, CancellationToken)

Persists an asset record, creating or overwriting any existing record with the same identifier.

public Task SaveAsync(AssetRecord asset, CancellationToken cancellationToken = default)

Parameters

asset AssetRecord

The asset record to save.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

SaveNotesAsync(string, string, CancellationToken)

Persists markdown notes for an asset, creating or overwriting any existing notes.

public Task SaveNotesAsync(string assetId, string markdown, CancellationToken cancellationToken = default)

Parameters

assetId string

The unique asset identifier.

markdown string

The markdown text to save.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task