FileDatabase refactor for normalization and consistency
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using DeepDrftContent.FileDatabase.Models;
|
||||
using IndexType = DeepDrftContent.FileDatabase.Services.IndexType;
|
||||
|
||||
namespace DeepDrftContent.FileDatabase.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for creating index instances
|
||||
/// </summary>
|
||||
public interface IIndexFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an index of the specified type
|
||||
/// </summary>
|
||||
Task<IIndex?> CreateIndexAsync(IndexType type, string rootPath);
|
||||
|
||||
/// <summary>
|
||||
/// Loads an existing index of the specified type
|
||||
/// </summary>
|
||||
Task<IIndex?> LoadIndexAsync(IndexType type, string rootPath);
|
||||
|
||||
/// <summary>
|
||||
/// Loads existing index or creates new one if loading fails
|
||||
/// </summary>
|
||||
Task<IIndex?> LoadOrCreateIndexAsync(IndexType type, string rootPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for creating index data objects
|
||||
/// </summary>
|
||||
public interface IIndexDataFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates index data for serialization
|
||||
/// </summary>
|
||||
object CreateIndexData(IndexType type, IIndex index);
|
||||
|
||||
/// <summary>
|
||||
/// Creates index instance from data
|
||||
/// </summary>
|
||||
IIndex CreateIndexFromData(IndexType type, object indexData);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using DeepDrftContent.FileDatabase.Models;
|
||||
using DeepDrftContent.FileDatabase.Services;
|
||||
|
||||
namespace DeepDrftContent.FileDatabase.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for registering media type factories
|
||||
/// </summary>
|
||||
public interface IMediaTypeRegistry
|
||||
{
|
||||
/// <summary>
|
||||
/// Register a factory for a specific media vault type
|
||||
/// </summary>
|
||||
void RegisterMediaType<TBinary, TParams, TDto, TMetaData, TVault>(MediaVaultType vaultType)
|
||||
where TBinary : FileBinary
|
||||
where TParams : FileBinaryParams
|
||||
where TDto : FileBinaryDto
|
||||
where TMetaData : MetaData;
|
||||
|
||||
/// <summary>
|
||||
/// Create a binary object from parameters
|
||||
/// </summary>
|
||||
FileBinary CreateBinary(MediaVaultType vaultType, object parameters);
|
||||
|
||||
/// <summary>
|
||||
/// Create a binary object from DTO
|
||||
/// </summary>
|
||||
FileBinary CreateBinaryFromDto(MediaVaultType vaultType, object dto);
|
||||
|
||||
/// <summary>
|
||||
/// Create a DTO from binary object
|
||||
/// </summary>
|
||||
FileBinaryDto CreateDto(MediaVaultType vaultType, FileBinary binary);
|
||||
|
||||
/// <summary>
|
||||
/// Create metadata from media object
|
||||
/// </summary>
|
||||
MetaData CreateMetaDataFromMedia(MediaVaultType vaultType, string entryKey, string extension, object media);
|
||||
|
||||
/// <summary>
|
||||
/// Create parameters from binary and metadata
|
||||
/// </summary>
|
||||
object CreateParams(MediaVaultType vaultType, FileBinary fileBinary, MetaData metaData);
|
||||
|
||||
/// <summary>
|
||||
/// Create media vault
|
||||
/// </summary>
|
||||
Task<MediaVault?> CreateVaultAsync(MediaVaultType vaultType, string rootPath);
|
||||
|
||||
/// <summary>
|
||||
/// Get the binary type for a vault type
|
||||
/// </summary>
|
||||
Type GetBinaryType(MediaVaultType vaultType);
|
||||
|
||||
/// <summary>
|
||||
/// Get the DTO type for a vault type
|
||||
/// </summary>
|
||||
Type GetDtoType(MediaVaultType vaultType);
|
||||
|
||||
/// <summary>
|
||||
/// Get the parameters type for a vault type
|
||||
/// </summary>
|
||||
Type GetParamsType(MediaVaultType vaultType);
|
||||
|
||||
/// <summary>
|
||||
/// Get the metadata type for a vault type
|
||||
/// </summary>
|
||||
Type GetMetaDataType(MediaVaultType vaultType);
|
||||
}
|
||||
Reference in New Issue
Block a user