Reputation: 69
Is it possible to access export metadata in MEF without storing
IList<Lazy<T,TM>> parts
,
but simply
IList<T> parts
Upvotes: 1
Views: 539
Reputation: 66733
No, you cannot get the metadata after the fact. You must import it along with the parts themselves.
Think of the import as a contract specifying the needs of your component. If it needs access to the metadata of some dependency, then you shouldn't hide that.
See also Nicholas Blumhardt's post about The Relationship Zoo, where this kind of relationship between components is described as A needs to know X about B before using it. The point is that this metadata is an aspect of the relationship between components, not something that should be handled separately somehow.
Upvotes: 1