Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1029663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:34:47+00:00 2026-05-16T12:34:47+00:00

i really dont get it work. say i have some classes with the same

  • 0

i really dont get it work.

say i have some classes with the same interface which i want to export.

[Export(typeof(IService))]
[ExportMetadata("ExportType", typeof(Service1))]   
public class Service1 : IService
{...}
[Export(typeof(IService))]
[ExportMetadata("ExportType", typeof(Service2))]   
public class Service2 : IService
{...}
[Export(typeof(IService))]
[ExportMetadata("ExportType", typeof(Service3))]   
public class Service3 : IService
{...}

now i have one class which import the IService and this class did not matter wich service it is.

public class Blup
{
   [ImPortingConstructor]
   public Blup(IService service)
   {}
}

what i try to achieve now is to build an ExportProvider which select the right Export on Compose.

Something like this:

public TypeExportProvider<TTypeToExport>() : ExportProvider
{}

i really have no idea how the

protected override IEnumerable<Export> GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)

should look like. maybe anyone know a blog to read about this. there a lot of custom ExportProvider samples out but not for this situation.

thx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:34:48+00:00Added an answer on May 16, 2026 at 12:34 pm

    Hi Kent if you look at the exports there are metadata called “ExportType”, this should be the selector for the custom exportprovider.
    but after posting here a found a blog post from glenn block. so for my special purpose i have to do is this:

    var catalog = new AggregateCatalog(); 
    catalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory)); 
    var defaults = new CatalogExportProvider(new TypeCatalog(typeof(Service2))); 
    var container = new CompositionContainer(catalog, defaults); 
    defaults.SourceProvider = container;
    

    never the less it would be nice to see how can i write a custom exportprovider which select the right export from metadata information. my problem is how can a choose the right information from ImportDefnition and how could i set the new Export(…) in GetExportsCore().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far I have the expression: http://[^\.]*\.mydomain\.com/((.*?)) Which matches... http://www.mydomain.com/Images/favicon.ico But I really dont
I keep getting this error and I really dont know why. I have tried
I want to copy an svg group but I really dont know what I
Let's say that I routinely have to work with files with an unknown, but
I am confused by C# right now. I have a bunch of classes, say
I'm using asp mvc 2 and I have a page which has some data
I am looking for some code as I don't really wanna get into the
I am really new to XMl and have been tasked with extracting some values
Forgive me if this is a dumb beginners problem, but I really don't get
I don't really get the concept of bytecode interpreter in the context of CPython.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.