MEF framework learning journey (ii) Contract

Source: Internet
Author: User

Note: by default, a type is used as a contract, rather than a string. Although the contract can be used as an arbitrary string, this will lead to ambiguity. For example, "sender" may be overwritten by "sender" in different class libraries of another project. Therefore, if you need to specify a string contract, we recommend that you use a namespace for the contract name, including the company name, for example, "contoso. Exports. Sender ".
According to the code above, all the export operations should be as follows:

Code segment

Namespace mefsample {[Export] public class exporter {...} [Export (typeof (exporter)] public class exporter1 {...} [Export ("mefsample. exporter ")] public class exporter2 {...}}

By default, the export feature uses the specific types of members as conventions. You can also explicitly specify the conventions by passing parameters to the feature constructor. The common mode is to allow components to explicitly export an interface or an abstract type contract, rather than a specific type. In this way, the importer can be completely decoupled from the specific implementation of the export.

 

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.