mef

Getting a Type Assembly in Windows 8

让人想犯罪 __ 提交于 2019-12-05 01:43:48
I'm trying to use MEF in Windows 8. In order to build up my AssemblyCatalog for the container, I need a reference to the assembly. In the past, I would have just done this: var catalog = new AssemblyCatalog(typeof(App).Assembly); Mysteriously, the Assembly property no longer exists on the Type object. Anybody know of a good work around? Is there another way to get the assembly? I could load it using Assembly.Load , but I would need the name of the assembly. I can't get that from the type either. Is using a DirectoryCatalog a possible alternate? I don't like the idea, but I'll do what I need to

MEF with ImportMany and ExportMetadata

此生再无相见时 提交于 2019-12-05 00:50:28
I've just started playing around with Managed Extensibility framework. I've got a class that's exported and a import statement: [Export(typeof(IMapViewModel))] [ExportMetadata("ID",1)] public class MapViewModel : ViewModelBase, IMapViewModel { } [ImportMany(typeof(IMapViewModel))] private IEnumerable<IMapViewModel> maps; private void InitMapView() { var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(typeof(ZoneDetailsViewModel).Assembly)); CompositionContainer container = new CompositionContainer(catalog); container.ComposeParts(this); foreach (IMapViewModel item in

SatisfyImportsOnce vs ComposeParts

半腔热情 提交于 2019-12-04 23:05:40
Can someone please explain the difference between SatisfyImportsOnce and ComposeParts and why one would work where the other doesn't? Specifically I have a MVC Web application that I am using MEF in. Below is some code (from that application) that works when I use SatisfyImportsOnce but doesn't when I use ComposeParts . My understanding is that ComposeParts creates composable parts from an array of attributed objects and composes them in the specified composition container and that SatisfyImportsOnce composes the specified part by using the specified composition service. To my simple monkey

ASP.NET MVC 4.0 Controllers and MEF, how to bring these two together?

荒凉一梦 提交于 2019-12-04 21:45:31
问题 I'm trying to create ASP.NET MVC module by using MEF. While I have no problems so far by using MEF without MVC, when it comes to exporting Controllers I have some difficulties. I used this approach as example http://kennytordeur.blogspot.de/2012/08/mef-in-aspnet-mvc-4-and-webapi.html I made it more complex by introducing an external dll, which contained a controller. But if I follow the idea of Kenny, then I need to have a common interface (like IMyTest in his example), however, as I plan to

Writing Visual Studio 2010 Plugin, would like to show a toolbox like Resharper in code editor

三世轮回 提交于 2019-12-04 18:21:18
问题 I would like to write a plugin for Visual Studio 2010 but in fact I face some problems. What I want to do seems easy, I would like that a little toolbox appears when selecting the text in code editor like in Resharper (little pen with menu that helps in refactoring) or like here: http://www.axtools.com/products-vs2010-extensions.php?tab=selection-popup I would like to know : Is there anu Visual Studio template that helps to start ? I try with "Editor Viewport Adornment" but I'm not sure of

Creating multiple instances of Imported MEF parts

流过昼夜 提交于 2019-12-04 17:58:03
问题 Currently my WPF application imports a part like this [Import(typeof(ILedPanel)] public ILedPanel Panel { get; set; } But this gives ma a single intance of the class that implements ILedPanel. What I really want to do is have the ability to create as many instances that I need. Please note there is only one Export for ILedPanel included with the software at any given time. (If I use an import with List that gives me one instance for every class implementing ILedPanel) Any suggestions? 回答1:

Caliburn.Micro + MEF + Modern UI: IContent events

独自空忆成欢 提交于 2019-12-04 13:26:18
问题 I've started a project using Caliburn.Micro and Modern UI (https://mui.codeplex.com) and am having some difficulty getting the navigation events of IContent to fire on my view model. I've already got the two hooked up to work with each other with the following: CM Bootstrapper: public class CMBootstrapper : Bootstrapper<IShell> { private CompositionContainer container; private DirectoryCatalog catalog; public CMBootstrapper() { } protected override void Configure() { catalog = new

How to import specific part from multi parts in MEF?

自闭症网瘾萝莉.ら 提交于 2019-12-04 12:18:30
问题 I am using MEF as DI container and the problem is that I want to import specific part from multiple parts. For example, I have following codes : public interface IService { void Send(); } [Export(typeof(IService))] public class Service : IService { public void Send() { Console.WriteLine("Service.Send"); } } [Export(typeof(IService))] public class FakeService : IService { public void Send() { Console.WriteLine("FakeService.Send"); } } [Import] public IService Service { get; set; } // ---> let

Locating Exports for Objects Created After ComposeParts Called

Deadly 提交于 2019-12-04 11:19:56
I've got a very simple app with a single export and multiple imports for the same type. After I call ComposeParts I can see that the import worked in the same class where I called ComposeParts from - the MyService property has been hooked up. The problem is that I have another UserControl that needs access to MyService and the property isn't set - it's in the same package etc. but it's not instatiated at the time I call ComposeParts. If I make my CompositionContainer public / static and call ComposeParts and pass the UserControl the MyService property is set but that's a horrible solution. Can

Is it possible to inject an existing instance into a MEF plugin?

女生的网名这么多〃 提交于 2019-12-04 10:59:23
We are creating an application which supports plugins using MEF. We are determining what type of plugins the user is able to create, and want to use dependency injection to provide this type of plugin with the data it needs. For example, we make a plugin that is able to display a list. To achieve this, it needs the existing instance of the IRepository for the type of data the list will display. The IRepository is created somewhere else in a datacontext class, so we are unable to let MEF itself create an instance of the IRepository. My idea is to inject the existing instance of the IRepository