Add UseRecovery convenience method to ImageContext

This commit is contained in:
Ben Olden-Cooligan 2019-07-17 21:22:53 -04:00
parent 49f1047463
commit 18dbc20395
2 changed files with 9 additions and 4 deletions

View File

@ -42,10 +42,7 @@ namespace NAPS2.Sdk.Tests
public void UseRecovery()
{
var recoveryFolderPath = Path.Combine(FolderPath, "recovery", Path.GetRandomFileName());
rsm = new RecoveryStorageManager(recoveryFolderPath);
ImageContext.FileStorageManager = rsm;
ImageContext.ConfigureBackingStorage<FileStorage>();
ImageContext.ImageMetadataFactory = rsm;
ImageContext.UseRecovery(recoveryFolderPath);
}
public ScannedImage CreateScannedImage()

View File

@ -195,6 +195,14 @@ namespace NAPS2.Images.Storage
set => fileStorageManager = value ?? throw new ArgumentNullException(nameof(value));
}
public ImageContext UseRecovery(string recoveryFolderPath)
{
var rsm = new RecoveryStorageManager(recoveryFolderPath);
FileStorageManager = rsm;
ImageMetadataFactory = rsm;
ConfigureBackingStorage<FileStorage>();
return this;
}
}
public class GdiImageContext : ImageContext