I am having an issue subscribing to events with the event Aggregator that comes as part of the prism framework.
If I use something such as
eventAggregato
MyEvent<IRequest>
and MyEvent<Profile>
are not the same, so the EventAggregator doesn't see this as the same event. To allow for covariant types, you can fix it with the out modifier in C# 4. Something like this should work:
public interface IMyClass<out T> where T : IRequest { }
public class MyClass<T> : IMyClass<T> where T : IRequest { }
public class MyEvent<TValue> : PubSubEvent<IMyClass<TValue>> where TValue : IRequest { }
Then your event aggregator would look something like:
_eventAggregator.GetEvent<MyEvent<IRequest>>().Subscribe(Received);
private void Received(IMyClass<IRequest> obj)
{
}
_eventAggregator.GetEvent<MyEvent<IRequest>>().Publish(new MyClass<Profile>());
Does this help?