Please simple code example of COM Aggregation
Posted on 2004-09-16
I have following situation, simplified
Connection COM object, people connect to this and the object creates a list of objects of type unknown, depends on situation.
People can ask a list of Patients, or a list of hospitals, or one of the other 170 objects the can matter. But for simplicity let us stick to these two or better one.
So the Connection COM-object does not know the kind of objects that are in the list, enven the list does not know.
The calling application does know what objects the Connection-objects has in list, so it knows which properties there are.
That is why I want to use Aggregation, the Connection-object cannot implement stubs for all possible objects, so the object need to publish their properties themselve.
To keep it simple, the calling application request a list of Patients, and wants to pick one of them to ask properties of that Patient, how do I write code like this?
I have a com-object, in-process, called Connection.dll, with interface IConnection
Connection has one property, that is List, for simplicity Items is sufficient.
I have a com-object patient.dll with Interface IPatient, two properties, Name an Address
Address also is a COM-object with one property Street
Please send me some example code, which shows me how to write the
Calling application to make it show Patient.name and Patient.Address.Street
For simplicity the wanted Patient is Item in the list.