jeudi 7 janvier 2021

Design approach for aggregating information from independent components

So, here is the overview of the components and classes that need to interact with each other:

Components and classes

When the download button in the ribbon view in the Project 1 is clicked in the UI, 3 different file collections, containing only file path strings (FilesCollection1, FilesCollection2 and FilesCollection3) in the Project 2 should be moved to the DevicesViewModel and joined together in the JointFilesCollection in the Project 3. After all files are joined to the JointFilesCollection, the download method of the DownloadService class in the Project 4 should be started. This download method takes the JOintFilesCollection as a parameter.

Which design approach can be suitable for achieving this goal?

What I could think of so far:

  • Create a PRISM composite command DownloadCommand. After the download button is clicked, the command will call the registered commands in the FilesViewModels 1, 2 and 3.
  • The registered commands in the FilesViewModels 1, 2 and 3 will send their FilesCollections as parameters of an EventAggregator object to the DevicesViewModel.
  • After files are joined to the JointFilesCollection, this collection should be sent as a parameter of an EventAggregator object to the DownloadService.

The main problem with this approach is that we can't determine exactly, when all 3 file collections where sent to the DevicesViewModel so that they could be joined together and sent to the DownloadService. All i can think of is some kind of flags in the DevicesViewModel, which hold the information, whether a particular FilesViewModel has already sent its collection. But that seems a bit awkward to me.

Aucun commentaire:

Enregistrer un commentaire