donderdag 17 april 2008

Reflection...

Today I got the question from a collegue if it was possible to instantiate a class, based on a result from a computation, without making use of an if-then-else, case or any other (logical) construction.


We found the answer in using reflection and attributes.
first of all, we created a class "ClassType":



After that, we created some classes, with each its own attribute:


after that, the attributes of a class in a certain assembly can be read (a little bit of pseudo code ;)

Geen opmerkingen: