Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Shared data across modules

$
0
0
Hi,

I am afraid I am not able to download the Prism template Pack as the Download site does not get resolved. However, at a first glance I would say that you could use the template, and then change the reference assemblies to Prism 5. In addition, I don't know what .NET version would the template be using, so you may need to update it to 4.5.

Nevertheless, the EventAggregator works with declared Events which would define a specific parameter type. Therefore, when ModuleB suscribes to that particular Event, it would actually know that the event's parameter type would be the one corresponding to the particular Event definition.
As you may see in the EventAggregation Quickstart, the FundAddedEvent class defined in the Infrastructure project, is declaring the Event with the generics parameter type that it would use. So when ModuleA would Publish the particular Event, it would need to necessarily pass the expected argument as well as the Suscriber would need to receive the argument on the EventHandler method:
publicclass FundAddedEvent : CompositePresentationEvent<FundOrder>
{
}
ModuleA - AddFundPresenter.cs (Publisher):
...
eventAggregator.GetEvent<FundAddedEvent>().Publish(fundOrder);
ModuleB - ActivityPresenter.cs (Suscriber):
...
publicvoid FundAddedEventHandler(FundOrder fundOrder){
...
If you don't want to reference ModuleA from ModuleB, you could create a common class on the Infrastructure project for example in order to be configured with ModelA important information, and be used as the Event argument.

I hope this helped you,
Regards.

Gabriel Ostrowsky.
https://blogs.southworks.net/gostrowsky

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>