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

  • SEARCH
  • Home
  • 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 8101687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:02:36+00:00 2026-06-05T23:02:36+00:00

Based on the answer for this question What's the difference between CompositionBatch and catalogs?

  • 0

Based on the answer for this question What's the difference between CompositionBatch and catalogs? which states that the use of composition batch is useful in situations where objects are built by some other component. This made me think, what real life example does it apply to? Then I started thinking about objects that get built that you aren’t in control of. How would you add those instances to the container if you can’t add parts that aren’t marked as an Export? The only thing that comes to mind is to setup a class with a member of the desired type and marking it as an export.

Is it possible to add instances to a container if they aren’t marked as an export?

  • 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-06-05T23:02:39+00:00Added an answer on June 5, 2026 at 11:02 pm

    I’m going to assume that you meant “classes not marked as an export” instead of “instances”.

    For .NET4.5 and up you can use MEF’s convention model.

    For .NET4, Mark Seemann has blogged about how you can make clever use of generics and property exports to export existing types. You can create a class like this:

    public class MefAdapter<T> where T : new()
    {
        private readonly T export;
    
        public MefAdapter()
        {
            this.export = new T();
        }
    
        [Export]
        public virtual T Export
        {
            get { return this.export; }
        }
    }
    

    And then you can construct a type catalog to export existing types which are not MEF-aware like this:

    var catalog = new TypeCatalog(
        typeof(MefAdapter<Foo>),
        typeof(MefAdapter<Bar>), 
        ...);
    

    You could modify this example to add support for types with constructor arguments, exporting interfaces instead of just the class type, etcetera.

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

Sidebar

Related Questions

This question is based on my previous question which I got a working answer
Based the accepted answer to this question I've setup a NetBeans/tomcat environment. In testing
This is a further question based on this answer: How can I implement a
Based on some answers to this question it appears that +alloc does some behind-the-scenes
The difference between this question and Remove Top Line of Text File with Powershell
In this question , I use xor operator between enum with [Flags] attribute as
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
THE ANSWER THAT WORKED FOR ME BASED ON AN ANSWER GIVEN while($post = mysql_fetch_array($tags))
In my previous question I got an excellent answer that helped me detect where
Based on a this logic given as an answer on SO to a different(similar)

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.