S
Sin Jeong-hun
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.
{
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.