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
666 B
C#
19 lines
No EOL
666 B
C#
using LANCommander.Server.ImportExport.Models;
|
|
|
|
namespace LANCommander.Server.ImportExport.Importers;
|
|
|
|
public abstract class BaseImporter<TRecord, TEntity> : IImporter<TRecord, TEntity>
|
|
{
|
|
protected ImportContext ImportContext { get; private set; }
|
|
|
|
public void UseContext(ImportContext context)
|
|
{
|
|
ImportContext = context;
|
|
}
|
|
|
|
public abstract Task<ImportItemInfo> GetImportInfoAsync(TRecord record);
|
|
public abstract bool CanImport(TRecord record);
|
|
public abstract Task<TEntity> AddAsync(TRecord record);
|
|
public abstract Task<TEntity> UpdateAsync(TRecord record);
|
|
public abstract Task<bool> ExistsAsync(TRecord record);
|
|
} |