D
David Veeneman
Is there a way that a class can subscribe to an event published by an object
that is a member of an array?
I have a class, Widget, that maintains information on a widget. I have a
number of widgets, so I maintain an array of type Widget[]. Whenever a
widget is changed, the Widget class invokes a Changed event. The Widget[]
array is a property of the WidgetHolder class, and that class needs to know
when the current Widget is changed.
Publishing and invoking the event is no problem. But how does WidgetHolder
subscribe to the event? I can't subscribe when I initialize WidgetHolder,
because I can only get to array properties when I access my Widget[]
property object. To get to individual widgets, I'd have to access Widget,
where i is an index number.
It looks like my choices are to use a collection class to wrap the array,
subscribe to the Change event in every member of Widget[] individually, or
pass a reference to WidgetHolder to each Widget as it is created. Is that
right, or am I missing something? Thanks in advance
David Veeneman
Foresight Systems
that is a member of an array?
I have a class, Widget, that maintains information on a widget. I have a
number of widgets, so I maintain an array of type Widget[]. Whenever a
widget is changed, the Widget class invokes a Changed event. The Widget[]
array is a property of the WidgetHolder class, and that class needs to know
when the current Widget is changed.
Publishing and invoking the event is no problem. But how does WidgetHolder
subscribe to the event? I can't subscribe when I initialize WidgetHolder,
because I can only get to array properties when I access my Widget[]
property object. To get to individual widgets, I'd have to access Widget,
where i is an index number.
It looks like my choices are to use a collection class to wrap the array,
subscribe to the Change event in every member of Widget[] individually, or
pass a reference to WidgetHolder to each Widget as it is created. Is that
right, or am I missing something? Thanks in advance
David Veeneman
Foresight Systems