It it possible to redirect events?



class Manager
{
public event ItemEventHandler ItHappened;
public Manager
{
Item i;
i.ItHappend+=new ItemEventHandler(OnItHappened);
}
void OnItHappened(...)
{
this.ItHappened();
}
}
class Item
{
public event ItemEventHandler ItHapped;
}

Above are simplified version of two classes. The client interacts with
the Manager, and the Manager has many 'Items'. This scheme works but
looks kind of a waste and overhead, because everytime an item fires
ItHapped, OnItHappened is called which simply fires the Manager's the
same event with the same parameters. I just wondered, if this thing
would be possible
class Client
{
void Init()
{
Manager m;
m.ItHappend += new ItemEventHandler(...);
~~~~~~~~~~~~~~~~~~~~~~ Let's call this thing
X
}
}
class Manager
{
public event ItemEventHandler ItHappened;
public Manager
{
Item i;
i.ItHappend+=somehow get X from Manager's ItHappend handlers;
}
}

If this is possible, then there's no need to call the trivial method
each time. Is it possible to get the handler list of the Manager's
ItHappened event at that point?
Thanks.
.



Relevant Pages

  • Re: It it possible to redirect events?
    ... You could call the GetInvocationList method on the delegate and that ... will give you an array of individual delegates that you could the attach ... public event ItemEventHandler ItHappened; ... the Manager, and the Manager has many 'Items'. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: It it possible to redirect events?
    ... You could call the GetInvocationList method on the delegate and that ... will give you an array of individual delegates that you could the attach ... public event ItemEventHandler ItHappened; ... the Manager, and the Manager has many 'Items'. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to Move Two Dialogs at Once
    ... >void CSvg::OnMove(int x, int y) ... you have one dialog that is the "manager" dialog whose position determines the ... Is this a correct characterization? ...
    (microsoft.public.vc.mfc)
  • RE: WPF Data-binding Validation problem
    ... void t_Elapsed(object sender, System.Timers.ElapsedEventArgs e) ... Microsoft Managed Newsgroup Support Team ... You can send feedback directly to my manager at: ...
    (microsoft.public.dotnet.framework)
  • Re: Generics and subclasses
    ... >I have two classes, Manager and Data. ... > Class Manager ... > Unfortunately Manager doesn't want to work with Interfaces (DataInterface, ... the dataVector accepts objects of type DataInterface. ...
    (comp.lang.java.programmer)