Event on an item in a collection

  • Thread starter Thread starter meyousikmann
  • Start date Start date
M

meyousikmann

This will be difficult to explain so bear with me. If anyone is
familiar with Tibco Rendezvous and/or Microsoft Messaging, this may
make more sense.

I've created a hierarchy of objects that looks something like this:

Tibco-->Transports-->Transport

Where Tibco is the overall component that owns a collection of
Transports and each Transport is an object of a class.

What I want to be able to do is have an event that will fire at the
Transport level whenever a message is received by the application but
I can't seem to figure out how to add an event to a collection item.
To make this question more generic, I simply want to have an event
attached to a collection item contained inside of a collection.

Here is some code:

public class Tibco : System.ComponentModel.Component
{
internal TransportCollection transports;

public Tibco()
{
this.transports = new TransportCollection();
}

public TransportCollection Transports
{
get
{
return this.transports;
}
}
}

public class TransportCollection :
System.Collections.Generic.List<Transport>
{
}

public class Transport
{
private System.String service;
private System.String network;
private System.String daemon;
internal ListenerCollection listeners;

public System.String Service
{
get
{
return this.service;
}
set
{
this.service = value;
}
}

public System.String Network
{
get
{
return this.network;
}
set
{
this.network = value;
}
}

public System.String Daemon
{
get
{
return this.daemon;
}
set
{
this.daemon = value;
}
}

public Transport()
{
this.listeners = new ListenerCollection();
}

public ListenerCollection Listeners
{
get
{
return this.listeners;
}
}
}


What I need is to be able to define an event for the Transport.

Any suggestions?
 
This will be difficult to explain so bear with me. If anyone is
familiar with Tibco Rendezvous and/or Microsoft Messaging, this may
make more sense.

I've created a hierarchy of objects that looks something like this:

Tibco-->Transports-->Transport

Where Tibco is the overall component that owns a collection of
Transports and each Transport is an object of a class.

What I want to be able to do is have an event that will fire at the
Transport level whenever a message is received by the application but
I can't seem to figure out how to add an event to a collection item.
To make this question more generic, I simply want to have an event
attached to a collection item contained inside of a collection.

One common way is to pass the collection as a parameter in the item
constructor. The collection items then call this.Parent.OnMyEvent().
Listeners register to the collection.

PS
 
One common way is to pass the collection as a parameter in the item
constructor. The collection items then call this.Parent.OnMyEvent().
Listeners register to the collection.

PS


















- Show quoted text -- Hide quoted text -

- Show quoted text -

Thanks for the reply. I can see how to make it work in code, however,
I probably should've mentioned that I would like to be able to assign
the event to the collection item at design time. My searching has
told me that I need to write my own design editor to support the
events tab on the property page for each collection item, but I have
yet to find information on how to do that or figure it out myself. If
anyone knows how to do this or knows of a source that explains it, I
would very much appreciate a nudge in the right direction.
 
Back
Top