How do I create a generic method with a generic in the where clause? (Man that's clear as mud!)
Posted
by
Jordan
on Stack Overflow
See other posts from Stack Overflow
or by Jordan
Published on 2010-12-29T18:08:50Z
Indexed on
2010/12/29
18:53 UTC
Read the original article
Hit count: 213
Is there a way of doing this:
protected void SubscribeToEvent<TEvent, TPayload>(Action<TPayload> a_action)
where TEvent : CompositePresentationEvent<TPayload>
{
TEvent newEvent = _eventAggregator.GetEvent<TEvent>();
SubscriptionToken eventToken = newEvent.Subscribe(a_action);
_lstEventSubscriptions.Add(new KeyValuePair<EventBase, SubscriptionToken>(newEvent, eventToken));
}
without requiring the user to specify a TPayload
parameter?
© Stack Overflow or respective owner