I've been successfully using MEF to obtain exported class instances. However, I came across a situation where I need to enumerate a set of exported derived classes without instantiating them. I've looked up CompositionContainer
's documentation and it only seems to be able to return object instances.
I know I could have a static Type field in each derived class and export it, or do my own reflection, but I'd like to know if there's a build-in way to mark classes with the [Export]
attribute and then enumerate their System.Type
.
As leppie said, there's no built in way to do this. This is by design. There's not necessarily a one-to-one mapping between exports and types (any number of parts could have property exports of type String, for example). Also, with different programming models, the part may have come from a configuration file or a dynamic programming language, so trying to get the CLR type associated with it might not make much sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With