This refactor splits the import and export functionality out of the ImportContext and adds an ExportContext. This also introduced separate importer and exporter implementations. Additionally, adding archive, save, scripts, and server files to the final export archive has been implemented at the exporter implementation for each instead of handling it in the context. This should be a good pattern if other files need to be added down the road.
19 lines
No EOL
701 B
C#
19 lines
No EOL
701 B
C#
using LANCommander.Server.ImportExport.Models;
|
|
|
|
namespace LANCommander.Server.ImportExport.Importers;
|
|
|
|
/// <summary>
|
|
/// Implementations should be able to process a single record. This will be called
|
|
/// by the import service to process records in its queue. Only one instance of
|
|
/// this needs to exist for each type.
|
|
/// </summary>
|
|
/// <typeparam name="TRecord"></typeparam>
|
|
public interface IImporter<TRecord, TEntity>
|
|
{
|
|
void UseContext(ImportContext context);
|
|
Task<ImportItemInfo> GetImportInfoAsync(TRecord record);
|
|
bool CanImport(TRecord record);
|
|
Task<TEntity> AddAsync(TRecord record);
|
|
Task<TEntity> UpdateAsync(TRecord record);
|
|
Task<bool> ExistsAsync(TRecord record);
|
|
} |