开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜