2
votes

In terms of communicating different messages within an app would a good idea be to create a class for each message type? Some of my messages will need a reference a model object.

For example DoThisMessageType:

Messenger.Default.Send<DoThisMessageType>(_doThisMessageType);

Messenger.Default.Register<DoThisMessageType>(this, delegate(DoThisMessageType dt)
{
  // do something
}); 

How do you use messages in your applications? Do you keep them all together in one spot?

1

1 Answers

3
votes

Definitely have a different class for each message type. This helps keep registration of handlers simple.

To help group your message types together, I would suggest having a MessageBase type that they all derive from. This opens up multiple ways of discovering all the message types that your app handles - using Reflection for example, or Resharper's Go to Implementation feature.