开发者

Why use MEF metadata instead of just extending the interface to include the metadata?

开发者 https://www.devze.com 2023-01-16 16:25 出处:网络
So intead of using ExportMetadata attribute, why not just extend the interface inst开发者_如何转开发ead?if you import Lazy<> stuff via MEF you can look into the metadata without instantiate your ob

So intead of using ExportMetadata attribute, why not just extend the interface inst开发者_如何转开发ead?


if you import Lazy<> stuff via MEF you can look into the metadata without instantiate your object.


Good question. I think that extending the interface is the correct thing to do whenever you have the option. It much better communicates intent.

However, we may need more fine-grained control over interfaces that we don't own. In those cases we can use ExportMetadata as a substitute.

In my opinion you should only use ExportMetadata when there is no other option available to you.

0

精彩评论

暂无评论...
验证码 换一张
取 消