tags:

views:

15

answers:

1

Not sure if this was a design decision but IMessenger.Send seems to be missing overload that accepts a token

+2  A: 

Assuming that by "token" you mean a string that identifies something about the message, there are several things you can do.

  1. You can use the NotificationMessage class as the message you're sending.

    Messenger.Default.Send(new NotificationMessage("Token"));
    
  2. If you want to use something other than a string as a token, you can use NotificationMessage.

    Messenger.Default.Send(new NotificationMessage<IToken>(new Token()));
    
  3. You can create your own message class and use it. This lets you register for only messages of your custom type. This is what I recommend.

    public class ErrorMessage : GenericMessage<Exception>
    {
        public ErrorMessage(Exception content) : base(content)
        {
        }
        public ErrorMessage(object sender, Exception content) : base(sender, content)
        {
        }
        public ErrorMessage(object sender, object target, Exception content) : base(sender, target, content)
        {
        }
    }
    
Matt Casto
I agree with this too.
Rick Ratayczak