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 7640051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:34:49+00:00 2026-05-31T08:34:49+00:00

I recognized, that MEF is limited for metro style apps. There is no container

  • 0

I recognized, that MEF is limited for metro style apps. There is no container anymore, so how can I get specific exported values like ILogger logger = container.GetExportedValues<ILogger>();?
Is the any tutorial available covering the metro version of MEF?

Thanks for Help,
Eny

  • 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-31T08:34:51+00:00Added an answer on May 31, 2026 at 8:34 am

    As I already wrote in the comment, I don’t really like this approach, but it is the best what I have up to this moment:

    public class CompositionContainer
    {
        private readonly CompositionService _service;
    
        public CompositionContainer(CompositionService service)
        {
            _service = service;
        }
    
        public T GetExportedValue<T>()
        {
            var factoryProvider = new FactoryProvider<T>();
            _service.SatisfyImportsOnce(factoryProvider);
            return factoryProvider.Factory.CreateExport().Value;
        }
    
        private class FactoryProvider<T>
        {
            [Import]
            public ExportFactory<T> Factory;
        }
    }
    

    and the simple use-case might be this one:

    class Program
    {
        static void Main()
        {
            var catalog = new ApplicationCatalog();
            var container = new CompositionContainer(catalog.CreateCompositionService());
            for (int i = 0; i < 5; i++)
            {
                var dude = container.GetExportedValue<IDude>();
                Console.WriteLine(dude.Say());
            }
        }
        public interface IDude
        {
            string Say();
        }
    
        [Export(typeof(IDude))]
        public class Eminem : IDude
        {
            private static int _instanceNo;
            private readonly string _phrase;
    
            public Eminem()
            {
                _instanceNo++;
                _phrase = string.Join(" ", Enumerable.Range(0, _instanceNo)
                    .Select(_ => "yo!"));
            }
    
            public string Say()
            {
                return _phrase;
            }
        }
    }
    

    I don’t care about performance at this moment, but I guess I’ll add caching of factory providers or factories later

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

Sidebar

Related Questions

I'm a bit worried if this function sends emails that can be recognized correctly
I want to know how it can be recognized that something is taped to
I have a route that works (recognized, can follow it) in a Rails 3
There is a LESS plug-in for PhpStorm *.less files are indeed recognized, in that
I recognized that calling a method on an Oracle Object Type takes longer when
I have long recognized that any set of whitespace in an HTML file will
I have looked over the Repository pattern and I recognized some ideas that I
1) How can the processor recognize the device requesting the interrupt? 2) Given that
I have PDF files that have been recognized using the OCR Text Recognition ->
I tried to recover a password. When thinking of this I recognized that the

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.