Combat MEF (3) Only members of the class are exported

Source: Internet
Author: User

Through the introduction of the previous two articles, I am sure you will understand that there are many useful values in MEF. In the previous article we also discussed the import and export, for export import, today we dig a little bit, well, just a little bit deeper, it will not be difficult, please be assured, if you feel that the article boring, may wish to drink milk while reading.

In the previous article we all exported the entire type (the entire class), but sometimes we might consider exporting only certain members of a class, such as a property or a field.

Let's not talk about the theory, so that everyone can not drink milk, or directly serve the bar. To facilitate testing, the following example writes the components in the current assembly, which is in the same project, and then uses Assemblycatalog to find them.

First, define a public interface IWork.

The interface is then implemented using two classes respectively.

Next, we define a general class that contains two properties, and returns an instance of the Firstwork class and the Secondwork class, respectively.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.