Re: events that fire events that fire events....a bad thing?



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.

.