I inherited a WPF/Prism/Unity MVVM application and I need to link in a Class Library that communicates externally over a serial port. The serial port library publishes Events for errors and messages.
I'm new to Prism, but I've used Unity some years back. The Prism application (lets call it PrismApp) is a base PrismApplication, with two modules: main and settings. My serial port library (lets call it LibSerial) wraps the base communications protocol and publishes three events: ConnectionEventReceived, ErrorEvent and MessageReceived. LibSerial has functions for Connect, StartSession and Send.
My questions are:
- Where do I instantiate my LibSerial? Do I create a Model for it or can I instantiate LibSerial in my base PrismApplication?
- How do I publish events to my ViewModels? I assume I would consume the LibSerial Events somewhere and use and EventAggregator to push various EventArgs up into the viewmodels?
- How would I call my LibSerial start/startsession/send functions from within PrismApp? Would that be a DeleagateCommand in a ViewModel that calls a pubsub.publish?
Thanks Everyone!