MEF framework learning journey (8) avoiding discovery

Source: Internet
Author: User

In some cases, you may need to prevent components from being discovered as part of a directory. For example, a part may be a base class from which it should be inherited rather than used. You can achieve this in two ways. First, you can use the abstract keyword for the component class. Abstract classes can provide inherited export to classes derived from abstract classes, but they are not provided for export.

If you cannot make a class an abstract class, you can use the partnotdiscoverable feature to modify it. Components modified with this feature will not be included in any directory. The following example demonstrates these modes. Dataone will be found in the directory. Since datatwo is abstract, it will not be discovered. Datathree uses the partnotdiscoverable feature, so it will not be discovered.

Code segment

[Export] public class dataone {// This part will be discovered // as normal by the catalog .} [Export] public abstract class datatwo {// This part will not be discovered // By the catalog .} [partnotdiscoverable] [Export] public class datathree {// This part will also not be discovered // By the catalog .}

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.