-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
SightKeeper.Data/Binary/Replication/DataSets/MultiDataSetReplicator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Collections.Immutable; | ||
using SightKeeper.Data.Binary.Model.DataSets; | ||
using SightKeeper.Data.Binary.Services; | ||
using SightKeeper.Domain.Model.DataSets; | ||
|
||
namespace SightKeeper.Data.Binary.Replication.DataSets; | ||
|
||
internal sealed class MultiDataSetReplicator | ||
{ | ||
public MultiDataSetReplicator(FileSystemScreenshotsDataAccess screenshotsDataAccess) | ||
{ | ||
_classifierReplicator = new ClassifierDataSetReplicator(screenshotsDataAccess); | ||
_detectorReplicator = new DetectorDataSetReplicator(screenshotsDataAccess); | ||
_poser2DReplicator = new Poser2DDataSetReplicator(screenshotsDataAccess); | ||
_poser3DReplicator = new Poser3DDataSetReplicator(screenshotsDataAccess); | ||
} | ||
|
||
public HashSet<DataSet> Replicate(ImmutableArray<PackableDataSet> packableDataSets, ReplicationSession session) | ||
{ | ||
return packableDataSets.Select(dataSet => Replicate(dataSet, session)).ToHashSet(); | ||
} | ||
|
||
private readonly ClassifierDataSetReplicator _classifierReplicator; | ||
private readonly DetectorDataSetReplicator _detectorReplicator; | ||
private readonly Poser2DDataSetReplicator _poser2DReplicator; | ||
private readonly Poser3DDataSetReplicator _poser3DReplicator; | ||
|
||
private DataSet Replicate(PackableDataSet packableDataSet, ReplicationSession session) | ||
{ | ||
return packableDataSet switch | ||
{ | ||
PackableClassifierDataSet classifierDataSet => _classifierReplicator.Replicate(classifierDataSet, session), | ||
PackableDetectorDataSet detectorDataSet => _detectorReplicator.Replicate(detectorDataSet, session), | ||
PackablePoser2DDataSet poser2DDataSet => _poser2DReplicator.Replicate(poser2DDataSet, session), | ||
PackablePoser3DDataSet poser3DDataSet => _poser3DReplicator.Replicate(poser3DDataSet, session), | ||
_ => throw new ArgumentOutOfRangeException(nameof(packableDataSet)) | ||
}; | ||
} | ||
} |