Format:
Recent snippets matching tags of MEF
private IEnumerable<MemberInfo> GetImportMembers(Type type) { var local = new HashSet<string>(); if (type.IsAbstract) { yield break; } foreach (var member in GetDeclaredOnlyImportMembers(type)) {
35 Views
no comments
namespace Entity { public interface IBase { string Name { get; } } [Export("Base2", typeof(IBase))] [PartCreationPolicy(CreationPolicy.NonShared)] public class Base2 : IBase
38 Views
no comments
//this is the MEF Team Code namespace System.ComponentModel.Composition.AttributedModel { internal class AttributedPartCreationInfo : IReflectionPartCreationInfo { private IEnumerable<MemberInfo> GetImportMembers(Type type) { if (type.IsAbstract) { yield break;
34 Views
no comments
using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; using System.Reflection; namespace MEFFactory { public interface IMessage {
83 Views
no comments
using System; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; using System.Reflection; namespace HelloMEF { public interface IGreetings { void Hello();
47 Views
no comments
namespace Nowcom.Quicksilver { public interface IMessage { } } namespace Nowcom.Quicksilver { using System.ComponentModel.Composition;
186 Views
no comments
public class LookupExportProvider<T> : ExportProvider { private ILookup<string, T> _lookup; public LookupExportProvider(ILookup<string, T> lookup) { if (lookup == null) throw new ArgumentNullException("lookup"); _lookup = lookup; }
98 Views
2 comments
public class DictionaryCatalog<T> : ComposablePartCatalog { public DictionaryCatalog(IDictionary<string, T> dict) { InitializeParts(dict); } private void InitializeParts(IDictionary<string, T> dict) { var partDefinitions = new List<ComposablePartDefinition>();
71 Views
no comments
namespace Nowcom.Quicksilver { using System.ComponentModel.Composition.Primitives; using System.Linq; using System; using System.ComponentModel.Composition.ReflectionModel; using System.Collections.Generic; public class WrappedPartDefinition: ComposablePartDefinition {
60 Views
no comments
namespace Nowcom.Quicksilver { using System; using System.Reflection; using System.Windows; using System.Collections.Generic; using System.ComponentModel.Composition; [Export] public class ViewContainer
158 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; namespace DynamicObjectContracts { public class Program
308 Views
no comments
public interface IRuleMetadata { [DefaultValue(0)] int ExecutionOrder { get; } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] public class RuleAttribute : ExportAttribute, IRuleMetadata { public RuleAttribute(int executionOrder)
168 Views
no comments
public class LoggerRegistry : PartRegistry { public LoggerRegistry() { Part<PartConvention>() .ForTypesMatching(x => x.GetInterfaces().Contains(typeof(ILogger))) .Exports(x => x.Export<ExportConvention>() .ContractType<ILogger>() .ContractName<ILogger>() .Members(m => new[] { m }))
71 Views
no comments
public class ConventionPart<T> : IPartImportsSatisfiedNotification { /// <summary> /// Initializes a new instance of the <see cref="ConventionPart{T}"/> class. /// </summary> public ConventionPart() { } [ImportMany]
94 Views
no comments
public class ViewModelInitializer<TViewModel,TModel> where TViewModel : IViewModel<TModel> { private Func<TViewModel> _viewModelFactory; public ViewModelInitializer(Func<TViewModel> viewModelFactory) { _viewModelFactory = viewModelFactory; } public void Initialize(FrameworkElement view, TModel model)
280 Views
no comments
public class ConfigurationExportProvider : ExportProvider { protected override IEnumerable<Export> GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition) { if (ConfigurationManager.AppSettings.AllKeys.Contains(definition.ContractName)) { var value = ConfigurationManager.AppSettings[definition.ContractName]; yield return new Export(definition.ContractName, () => value); } else
77 Views
no comments
class Program { static void Main(string[] args) { var instance = new Program(); var cat = new AssemblyCatalog(typeof(Program).Assembly); var container = new CompositionContainer(cat); container.ComposeParts(instance); foreach (var plug in instance.Plugins)
246 Views
no comments
// Below RecentlyUsedTrackerConfiguration provides configuration information through property exports. MEF pulls on the property getters and exports that info. // If the part needs to be data drvien, you can still access a service behind the scenes in the getter (or the constructor) to get the info. public class RecentlyUsedTrackerConfiguration { public RecentlyUsedTrackerConfiguration() { //set values here }
257 Views
no comments
class Program { private static ImpCls s_imp = new ImpCls(); private static string[] s_beforeState; static void Main(string[] args) { var c = new TypeCatalog(typeof(ExpMtd1)); var catalog = new AggregateCatalog(c); var container = new CompositionContainer(catalog);
92 Views
no comments
using System.ComponentModel.Composition; using Microsoft.Practices.Composite.Events; //this version uses a static backing field so that the instance is automatically shared across all containers. public class EventAggregatorPart { private static IEventAggregator _eventAggregator; static EventAggregatorPart() {
396 Views
no comments
namespace Nowcom.Quicksilver.GoogleAnalytics { public class Test { [AnalyticsCategories("TEST")] public readonly string TestEvent = "TestEvent"; } public interface IAnalyticsCategoriesMetadata {
171 Views
no comments
var catalog = new DirectoryCatalog(@".\"); var rootCatalog = new FilteredCatalog(catalog, cpd=>!cpd.Metadata.ContainsKey("Scope") || (cpd.Metadata.ContainsKey("Scope") && cpd.Metadata["Scope"].Equals("Root")); var childCatalog = new FilteredCatalog(catalog, cpd=>cpd.Metadata.ContainsKey("Scope") && cpd.Metadata["Scope"].Equals("Child")); var rootContainer = new CompositionContainer(rootCatalog); var childContainer = new CompositionContainer(childCatalog, rootContainer);
117 Views
no comments
/* Sample below illustates export inheritance where the base export provides metadata that is overriden by the inheritor using a custom metadata attribute. In this case OverridingExtension implements IExtension but then explicitly overrides the base and provides new metadata. The result is a single export rather than two exports. Notice the inheritor is using an InheritedExport attribute + a custom metadata attribute to override rather than using a custom InheritedExport.
368 Views
no comments
//Design time VM [Export] public ContactVM GetViewModel() { var contact = new Contact() { FirstName = "John", LastName = "Doe", City = "Design time",
518 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
