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.
17 lines
No EOL
606 B
C#
17 lines
No EOL
606 B
C#
using LANCommander.Server.ImportExport.Models;
|
|
|
|
namespace LANCommander.Server.ImportExport.Exporters;
|
|
|
|
/// <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 IExporter<TRecord, TEntity>
|
|
{
|
|
void UseContext(ExportContext context);
|
|
Task<ExportItemInfo> GetExportInfoAsync(TEntity record);
|
|
bool CanExport(TRecord record);
|
|
Task<TRecord> ExportAsync(Guid id);
|
|
} |