This project is read-only.

ContentLoader to pick content from MEF Plugin if not found in current assembly.

Feb 17, 2014 at 6:27 AM
I've read the MUI MEF Guide, but I'm wondering how I would construct a ContentLoader that would try to obtain the Content from the MEF Exported content (MEF plugin assembly), if and if not available, fallback to content from where the default content loader gets it from (current assembly).

Anyone have any ideas how to do this?
Feb 18, 2014 at 9:00 PM
..actually, this was very easy to accomplish. I'll post it here just in case it helps anyone:

I modified the MEFContentLoader to call its base implementation of LoadContent if a matching exported URI couldn't be found:
    public class MEFContentLoader : DefaultContentLoader
        private Lazy<IContent, IContentMetadata>[] Contents { get; set; }

        protected override object LoadContent(Uri uri)
            // lookup the content based on the content uri in the content metadata
            var content = (from c in this.Contents
                           where c.Metadata.ContentUri == uri.OriginalString
                           select c.Value).FirstOrDefault();

            if (content == null)
                return base.LoadContent(uri);

                return content;