C
cody
Hi!
we are building an xml-export tool to export our business entities from
out app. we use reflection to determine the data type of properties.
e.g. we have a class Customer with a CustNo property, and reflection
tells us that the type is int. so far so good.
Now we have a ContactCollection (which inherits from MyBaseColletion)
inside the Customer class.
How can we determine the type of the list, that is, the type of the
elements inside the list? We could check the return type of the indexer
for example, but what if the list doesn't have any? Is there another way
to determine the element type or at least enforce the programmer to
provide an indexer?
Note that we do not have instance of the classes at the timer the export
is configured, that is somebody chooses which fields and how deep the
export should go. Even if we had an instance at that time, if the
collection would be empty then we also do not see the type if its contents.
The only thing I could think of where a static abstract property say,
GetElementType which must be overridden in each class (I know that this
is not possible).
I came across a similar problem when trying to attach static data to
classes for a data access layer a few week ago.
Am I missing something???
we are building an xml-export tool to export our business entities from
out app. we use reflection to determine the data type of properties.
e.g. we have a class Customer with a CustNo property, and reflection
tells us that the type is int. so far so good.
Now we have a ContactCollection (which inherits from MyBaseColletion)
inside the Customer class.
How can we determine the type of the list, that is, the type of the
elements inside the list? We could check the return type of the indexer
for example, but what if the list doesn't have any? Is there another way
to determine the element type or at least enforce the programmer to
provide an indexer?
Note that we do not have instance of the classes at the timer the export
is configured, that is somebody chooses which fields and how deep the
export should go. Even if we had an instance at that time, if the
collection would be empty then we also do not see the type if its contents.
The only thing I could think of where a static abstract property say,
GetElementType which must be overridden in each class (I know that this
is not possible).
I came across a similar problem when trying to attach static data to
classes for a data access layer a few week ago.
Am I missing something???