public ModelBackup CreateBackup() { var backup = new ModelBackup(); var accessor = GetTypeAccessor(); foreach (var propertyName in GetBackupProperties()) { var value = accessor[this, propertyName]; backup.BackupValues[propertyName] = value; } return(backup); }
public void RestoreBackup(ModelBackup backup) { var accessor = GetTypeAccessor(); foreach (var propertyName in GetBackupProperties()) { var value = backup.BackupValues[propertyName]; if (!IsEqualToBackup(accessor[this, propertyName], value)) { accessor[this, propertyName] = value; } } }