views:

692

answers:

4

I'm looking for samples / best practices of Event Aggregator implementation.

Anyone help ?

A: 

The best sample of an Event Aggregator would probably be the one from Prism. This was designed by the Patterns and Practices team as part of the Composite WPF and Silverlight Guidance.

Reed Copsey
@Reed : Does it provides ordered queuing mechanism ?
Yoann. B
@Yoann. B: I don't think it does out of the box, but it's interface based, and would be fairly easy to extend to include ordering.
Reed Copsey
A: 

there's a nice one in the MVVM Light toolkit by Laurent Bugnion. Here's the interface

public interface IMessenger
{
    void Register<TMessage>(object recipient, Action<TMessage> action);
    void Register<TMessage>(object recipient, bool receiveDerivedMessagesToo, Action<TMessage> action);
    void Send<TMessage>(TMessage message);
    void Send<TMessage, TTarget>(TMessage message);
    void Unregister(object recipient);
    void Unregister<TMessage>(object recipient);
    void Unregister<TMessage>(object recipient, Action<TMessage> action);
}
Mark Heath