mef

Can I use MEF to create an extensible factory?

主宰稳场 提交于 2019-12-23 22:19:15
问题 Let me start by saying that I am coming at this with limited MEF experience and have accomplished my goals using both Castle and Unity previously. I'm hoping something similar can be done with MEF. In short, what I need is a factory class that can instantiate objects by name. More specifically, I will have an abstract base class such as: public abstract class TheBaseClass { ... } There will be any number of subclasses that derive from the base class: public class OneSubClass : TheBaseClass {

Catch unhandled exceptions from editor

雨燕双飞 提交于 2019-12-23 21:19:48
问题 We are using MEF within our WPF application (MVVM) to embedd external editors. At some point in our main view there is a content element where the editor is going to be placed in. Now we would like to catch any unhandled exception from that editor and then reload the editor. The only thing I have found is to use DispatcherUnhandledException from the Application class. From there I would have to somehow reach the main view editor and tell it to reload the crashed editor. I was wondering if

How to add System.ComponentModel.Composition.dll in VS2010 IDE?

℡╲_俬逩灬. 提交于 2019-12-23 18:11:51
问题 With command line, I use /r: to add reference with VS2010 as follows. csc Program.cs /r:System.ComponentModel.Composition.dll /r:SharedLibrary.dll How can I add reference in VS2010 IDE? I tried to right click on the Solution Explorer, then clicked "Add Reference ...", but I can't find the System.ComponentModel.Composition . 回答1: The Add Reference Dialog from the Productivity Power Tools is filtering for 3.5 framework assemblies because you're application is undoubtedly targeting 3.5. The

MEF & Silverlight: How do I navigate to a page in another XAP?

ぐ巨炮叔叔 提交于 2019-12-23 15:53:08
问题 I'm very lost on how to do this. I understand MEF and can load services and classes from another XAP using the ubiquitous DeploymentCatalogService found in many blog posts. What I don't understand is how to actually load and navigate to a PAGE from another XAP. What I'd like to do is have my main application be able to call the NavigationService and provide it with the name of a Page that should exist. Like: NavigationService.Navigate(new Uri("/Test", UriKind.Relative)); It's up to one of the

Passing parameters to plugin constructor via MEF on .NET Core?

核能气质少年 提交于 2019-12-23 14:19:01
问题 I spent several hours trying to figure out how to pass parameters to a plugin constructor via MEF (System.Composition) but all to no avail. Needless to say, there are very few relevant docs and a look through the source code didn't help. This used to be really easy to do, using the CompositionHost.ComposeExportedValue method, but in the .NET Core version I can't seem to find anything that works. I've enclosed my incomplete code, below, followed by the exception that is thrown. Any help in

MEF CachedAssemblyCatalog - Lazy Loading of Assemblies

扶醉桌前 提交于 2019-12-23 13:13:42
问题 I'm very interested in the CachedAssemblyCatalog class introduced in the samples provided in older versions of MEF - which allows loading a small assembly containing just the export data instead of the entire assembly, and only loading the full assembly when a part from that assembly is required. I'd like to use this feature in my application, but I'm not really sure about the stability/reliability of this code, and whether there are any future plans regarding this feature. Is it scheduled to

Silverlight Navigation using Mvvm-light(oobe)+MEF?

北城余情 提交于 2019-12-23 12:20:15
问题 What is the best approach for navigating between UserControls/Pages(out of browser experience)? I'm fairly new to Silverlight and even newer to the mvvm pattern. How well does the Navigation Framework Integrate with the MVVM Light Toolkit? A snippet for general application flow control with the two would be great. The plan was to use the Navigation Framework for general flow or using Jeremy Likeness's approach to region management(http://csharperimage.jeremylikness.com/search/label/regions)

C#/MEF doesn't work with a base class without parameterless constructor

纵饮孤独 提交于 2019-12-23 11:53:20
问题 I have a Prim class that implements an IPrimitiveDecomposer interface for MEF and inherits Node base class. public class Node { public Node() { } } public interface IPrimitiveDecomposer { bool Match(Node node); } [Export(typeof(IPrimitiveDecomposer))] public class Prim : Node, IPrimitiveDecomposer { public bool Match(Node node) {return true;} } However, when I inherit a class that doesn't have a parameterless constructor, MEF's ComposeParts() method cannot import the Prim object. I added the

Automatically call method after part has been composed in MEF

无人久伴 提交于 2019-12-23 10:56:06
问题 Is there a way to specify that a method gets called automatically after a part has been composed? The method could be called on the composed part or in the class doing the composition. 回答1: Yes. If your class implements the IPartImportsSatisfiedNotification interface, then the MEF container will call OnImportsSatisfied at the right time. 回答2: Taking this approach will introduce a temporal coupling into your class - it will be dependent on some outsider calling methods in just the right order

Where is the “System.Composition.TypedParts.dll”?

六月ゝ 毕业季﹏ 提交于 2019-12-23 10:55:01
问题 I am trying to use the ContainerConfiguration type from the Managed Extensibility Framework (MEF). According to here, it lives in " System.Composition.TypedParts.dll " which is part of .NET Framework 4.5. But I cannot find it in Add Reference for a .NET 4.5 application. Where can I find this DLL? 回答1: It turned out to be part of MEF 2, which needs to be installed with NuGet. It's not distributed with .NET Framework. 来源: https://stackoverflow.com/questions/25658599/where-is-the-system