Table of Contents

Class InMemoryDataBlockRegistry

Namespace
Datafication.Server.Core.Registry
Assembly
Datafication.Server.Core.dll

An in-memory implementation of IDataBlockRegistry that stores DataBlocks with thread-safe access.

public class InMemoryDataBlockRegistry : IDataBlockRegistry
Inheritance
object
InMemoryDataBlockRegistry
Implements

Properties

Count

Gets the total number of registered DataBlocks.

public int Count { get; }

Property Value

int

Methods

Contains(string)

Checks if a DataBlock with the specified identifier exists.

public bool Contains(string id)

Parameters

id string

The unique identifier to check.

Returns

bool

True if the DataBlock exists; otherwise, false.

ContainsAsync(string, CancellationToken)

Asynchronously checks if a DataBlock with the specified identifier exists.

public Task<bool> ContainsAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The unique identifier to check.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<bool>

True if the DataBlock exists; otherwise, false.

GetAllDataBlockIds()

Gets all registered DataBlock identifiers.

public IEnumerable<string> GetAllDataBlockIds()

Returns

IEnumerable<string>

A collection of all registered DataBlock identifiers.

GetAllDataBlockIdsAsync(CancellationToken)

Asynchronously gets all registered DataBlock identifiers.

public Task<IEnumerable<string>> GetAllDataBlockIdsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<IEnumerable<string>>

A collection of all registered DataBlock identifiers.

GetDataBlock(string)

Retrieves a DataBlock by its identifier.

public DataBlock? GetDataBlock(string id)

Parameters

id string

The unique identifier of the DataBlock.

Returns

DataBlock

The DataBlock instance if found; otherwise, null.

GetDataBlockAsync(string, CancellationToken)

Asynchronously retrieves a DataBlock by its identifier.

public Task<DataBlock?> GetDataBlockAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The unique identifier of the DataBlock.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<DataBlock>

The DataBlock instance if found; otherwise, null.

GetDataBlockMetadata(string)

Retrieves metadata for a DataBlock by its identifier.

public DataBlockMetadata? GetDataBlockMetadata(string id)

Parameters

id string

The unique identifier of the DataBlock.

Returns

DataBlockMetadata

The metadata for the DataBlock if found; otherwise, null.

GetDataBlockMetadataAsync(string, CancellationToken)

Asynchronously retrieves metadata for a DataBlock by its identifier.

public Task<DataBlockMetadata?> GetDataBlockMetadataAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The unique identifier of the DataBlock.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<DataBlockMetadata>

The metadata for the DataBlock if found; otherwise, null.

RegisterDataBlock(string, DataBlock, DataBlockMetadata?)

Registers a DataBlock with the specified identifier.

public void RegisterDataBlock(string id, DataBlock dataBlock, DataBlockMetadata? metadata = null)

Parameters

id string

The unique identifier for the DataBlock.

dataBlock DataBlock

The DataBlock instance to register.

metadata DataBlockMetadata

Optional metadata associated with the DataBlock.

Exceptions

ArgumentNullException

Thrown when id or dataBlock is null.

ArgumentException

Thrown when id is empty or whitespace.

RegisterDataBlockAsync(string, DataBlock, DataBlockMetadata?, CancellationToken)

Asynchronously registers a DataBlock with the specified identifier.

public Task RegisterDataBlockAsync(string id, DataBlock dataBlock, DataBlockMetadata? metadata = null, CancellationToken cancellationToken = default)

Parameters

id string

The unique identifier for the DataBlock.

dataBlock DataBlock

The DataBlock instance to register.

metadata DataBlockMetadata

Optional metadata associated with the DataBlock.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task

UnregisterDataBlock(string)

Removes a DataBlock from the registry.

public bool UnregisterDataBlock(string id)

Parameters

id string

The unique identifier of the DataBlock to remove.

Returns

bool

True if the DataBlock was removed; otherwise, false.

UnregisterDataBlockAsync(string, CancellationToken)

Asynchronously removes a DataBlock from the registry.

public Task<bool> UnregisterDataBlockAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The unique identifier of the DataBlock to remove.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<bool>

True if the DataBlock was removed; otherwise, false.