Re: events that fire events that fire events....a bad thing?
- From: "Bruce Wood" <brucewood@xxxxxxxxxx>
- Date: 30 Jan 2007 17:39:12 -0800
On Jan 30, 4:10 pm, "Daniel" <nos...@xxxxxxxxxxxxxx> wrote:
Hi,
I have a scenario where a class is wrapped inside another but the inner
class triggers an event. I want that event to be accessed outside of the
wrapper. As a result i do code such as:
public Table()
{
_Logic = LogicFactory.Instance.GetLogic();
_Logic.MoveDone += OnMoveDone;
}
public void OnMoveDone(int tableId, int? playerId, bool bBroadCast)
//fired by event in _Logic class
{
MoveDone (tableId, playerId, bBroadCast); //trigger event for
this wrapper class
}
So my query is, the above way of doing this is ok? Or is there some way i
canmake the MoveDone event in _Logic available to an external class directly
without the need for a seemingly redundant inner method. Something like:
public event MoveDoneEvent
{
get { return _Logic.MoveDone; }
}
The way you've done it is a common idiom. The only other way I know of
is to expose the actual inner class, something like:
public Logic Logic
{
get { return this._logic; }
}
but one generally doesn't want clients messing directly with internal
objects, so this isn't commonly used.
.
- Follow-Ups:
- Re: events that fire events that fire events....a bad thing?
- From: Bob Powell [MVP]
- Re: events that fire events that fire events....a bad thing?
- References:
- Prev by Date: Re: Regex repeating capture
- Next by Date: Re: smo create database object
- Previous by thread: events that fire events that fire events....a bad thing?
- Next by thread: Re: events that fire events that fire events....a bad thing?
- Index(es):