mef

MEF with ImportMany and ExportMetadata

a 夏天 提交于 2020-01-13 07:55:30
问题 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

Custom configuration sections in MEF exporting assemblies

随声附和 提交于 2020-01-12 20:19:02
问题 I have an assembly that contains classes that import a number of classes from different assemblies that are not referenced at compile time but are discovered at runtime via a directory catalog. The exporting classes want to define custom configuration sections for the config file in the importing assembly's host application. However, because the importing assembly's host application does not know the exporting assemblies at compile time, it cannot load the assembly to use the custom section

Custom configuration sections in MEF exporting assemblies

余生长醉 提交于 2020-01-12 20:18:21
问题 I have an assembly that contains classes that import a number of classes from different assemblies that are not referenced at compile time but are discovered at runtime via a directory catalog. The exporting classes want to define custom configuration sections for the config file in the importing assembly's host application. However, because the importing assembly's host application does not know the exporting assemblies at compile time, it cannot load the assembly to use the custom section

MEF GetExports<T, TMetaDataView> returning nothing with AllowMultiple = True

狂风中的少年 提交于 2020-01-12 05:41:24
问题 I don't understand MEF very well, so hopefully this is a simple fix of how I think it works. I'm trying to use MEF to get some information about a class and how it should be used. I'm using the Metadata options to try to achieve this. My interfaces and attribute looks like this: public interface IMyInterface { } public interface IMyInterfaceInfo { Type SomeProperty1 { get; } double SomeProperty2 { get; } string SomeProperty3 { get; } } [MetadataAttribute] [AttributeUsage(AttributeTargets

What should I use in Prism- MEF or Unity?

不羁的心 提交于 2020-01-12 04:48:06
问题 Found several good(related) questions here and here but all are nearly a year old. I will like to know in the current context of Prism development what is better or at least scenario where each is better. 回答1: They are two approaches to solving some-what overlapping scenarios. Unity shines when you are developing a modular application where users will be using a subset of the modules and modules are self-contained. MEF shines when you have a lot of 3rd party developers creating plug-ins for

Whither Managed Extensibility Framework for .NET?

坚强是说给别人听的谎言 提交于 2020-01-09 12:53:50
问题 Has anyone worked much with Microsoft's Managed Extensibility Framework (MEF)? Kinda sounds like it's trying to be all things to all people - It's an add-in manager! It's duck typing! I'm wondering if anyone has an experience with it, positive or negative. We're currently planning on using an generic IoC implementation ala MvcContrib for our next big project. Should we throw MEF in the mix? 回答1: We are not aiming for MEF to be an all-purpose IoC. The best way to think about the IoC aspects of

Getting IClassifier to work with custom content type

南楼画角 提交于 2020-01-07 05:46:08
问题 I am trying to add syntax highlighting for a custom content type based on text e.g. static class RTextContentType { public const string ContentTypeName = Constants.CONTENT_TYPE; [Export, Name(ContentTypeName), BaseDefinition("text")] internal static ContentTypeDefinition ContentTypeDefinition = null; // set via MEF } Then the classifier provider is declared like this, [Export(typeof(IClassifierProvider)), ContentType(Constants.CONTENT_TYPE)] class RTextClassifierProvider : IClassifierProvider

Converting a MEF application to utilize Rx (System.Reactive)

穿精又带淫゛_ 提交于 2020-01-06 08:10:22
问题 So the current situation is I have a program that is completely utilizing MEF. Now I want to make it utilize Rx as to allow it to scale to larger queries and allow the user to look over results as the various plugins return results. It is currently setup as such: Workflow: Query => DetermineTypes => QueryPlugins => Results Currently the code is all stored on GitHub if anyone needs to reference more than what I post below. ALeRT on GitHub The VS solution has a UI project (default StartUp

Visual Studio Extensibility / Margins

做~自己de王妃 提交于 2020-01-06 04:21:05
问题 I am trying to build a Margin (through MEF) as a VS addin. I need to get the lines that contain the definition of a method. I have found people doing such things but it seems most are parsing test. This seems like a really bad idea as it would obviously only work with languages you knew how to parse. In an addin I can access the document in a programmatic fashion using a higher level model: var fcm = _application.ActiveDocument.ProjectItem.FileCodeModel; var elem = fcm.CodeElementFromPoint

How do i get MEF container to inject himself

早过忘川 提交于 2020-01-05 10:33:25
问题 I'm using constructor injection with MEF Composition Container and I want to know how can I make the CompositionContainer inject itself on the instance of the object he is providing. 回答1: You can use one of the CompositionContainer.ComposeExportedValue methods to create a part from a given object. Here's a sample: class Program { static void Main(string[] args) { var container = new CompositionContainer(new ApplicationCatalog()); Console.WriteLine("Main: container [{0}]", container