public IEntityRestorePoint GetRestorePoint(params Type[] types) { lock (ioMutex) { var restorePointFiles = System.IO.Directory.GetFiles(RestorePointFolder, "*" + FileTypeExt); if (restorePointFiles.Length == 0) { return(null); } } var restorePoint = new EntityRestorePoint(); try { foreach (var type in types) { var entities = LoadEntities(type, RestorePointFolder); if (entities != null && entities.Count > 0) { restorePoint.AddEntities(type, entities); } } return(restorePoint); } finally { CreateBackup(restorePoint); ClearRestorePoint(); } }
private void CreateBackup(EntityRestorePoint restorePoint) { var backupFolder = GetBackupFolder(); IReadOnlyList <Type> types = restorePoint.GetEntityTypes(); foreach (var type in types) { var entities = restorePoint.Get(type); StoreEntities(type, entities, backupFolder); } RemoveOldBackups(); }
public IEntityRestorePoint GetRestorePoint(string path, params Type[] types) { lock (ioMutex) { var restorePointFiles = System.IO.Directory.GetFiles(path, "*" + FileTypeExt); if (restorePointFiles.Length == 0) { return(null); } } var restorePoint = new EntityRestorePoint(); foreach (var type in types) { var entities = LoadEntities(type, path); if (entities != null && entities.Count > 0) { restorePoint.AddEntities(type, entities); } } return(restorePoint); }