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
-
objectInMemoryDataBlockRegistry
- 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
idstringThe 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
idstringThe unique identifier to check.
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
idstringThe 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
idstringThe unique identifier of the DataBlock.
cancellationTokenCancellationTokenA 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
idstringThe 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
idstringThe unique identifier of the DataBlock.
cancellationTokenCancellationTokenA 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
idstringThe unique identifier for the DataBlock.
dataBlockDataBlockThe DataBlock instance to register.
metadataDataBlockMetadataOptional 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
idstringThe unique identifier for the DataBlock.
dataBlockDataBlockThe DataBlock instance to register.
metadataDataBlockMetadataOptional metadata associated with the DataBlock.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
UnregisterDataBlock(string)
Removes a DataBlock from the registry.
public bool UnregisterDataBlock(string id)
Parameters
idstringThe 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
idstringThe unique identifier of the DataBlock to remove.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<bool>
True if the DataBlock was removed; otherwise, false.