CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of mef
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
 
namespace StaticMEF
{
    class Program
by bnaya   October 18, 2011 @ 8:50am
102 Views
no comments
 
C#
// -----------------------------------------------------------------------
// <copyright file="MefBootstrapper.cs" company="CompDJ">
//     Copyright (c) CompDJ. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
 
namespace ConsoleApplication2
{
    using System;
    using System.Collections.Generic;
by rickrat   October 15, 2011 @ 1:13am
132 Views
no comments
 
C#
I have an issue with accessing certain public objects of my RESx files. I am working with a MEF solution around an MVC3 application. My 
RESx files are implemented as public so they are accessible across assemblies. However, this seems to be limited. 
 
The solution I have is just changing the Custom Tool to PublicResXFileCodeGenerator. This allows switching the accessor that is applied 
to the class from internal to public. However, there is a catch when we throw MEF into the mix.
 
Because MEF works on the principle of importing assemblies into an AppDomain and managing the export and import connections that it 
contains, the soft referencing that is implied does not connect one RESx file to another.
 
Project Brand
by Bryan Wood   March 10, 2011 @ 10:49am
Tags: MVC, asp.net, MEF, resx
187 Views
no comments
 
<system.diagnostics>
  <sources>
    <source name="System.ComponentModel.Composition" switchValue="Error">
      <listeners>
        <add name="fileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="Mef Composition.log" />
      </listeners>
    </source>
  </sources>
  <trace autoflush="true" indentsize="4" />
</system.diagnostics>
by bnaya   November 03, 2010 @ 5:03am
Tags: MEF, Debug, Config
279 Views
no comments
 
C#
private IEnumerable<MemberInfo> GetImportMembers(Type type)
        {
            var local = new HashSet<string>();
            if (type.IsAbstract)
            {
                yield break;
            }
 
            foreach (var member in GetDeclaredOnlyImportMembers(type))
            {
309 Views
no comments
 
C#
namespace Entity
{
public interface IBase
{
    string Name { get; }    
}
 
[Export("Base2", typeof(IBase))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class Base2 : IBase
by codding4fun   June 08, 2010 @ 1:55am
368 Views
no comments
 
C#
//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;
by codding4fun   June 08, 2010 @ 1:32am
314 Views
no comments
 
C#
 
by codding4fun   June 08, 2010 @ 1:27am
239 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
 
namespace MEFFactory
{
    public interface IMessage
    {
by JamesEggers   April 20, 2010 @ 2:45pm
Tags: MEF
574 Views
no comments
 
C#
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
 
namespace HelloMEF
{
    public interface IGreetings
    {
        void Hello();
by Andy Sherwood   April 20, 2010 @ 11:32am
Tags: MEF
233 Views
no comments
 
C#
namespace Nowcom.Quicksilver
{
  public interface IMessage
  {
  }
}
 
namespace Nowcom.Quicksilver
{
    using System.ComponentModel.Composition;
595 Views
no comments
 
C#
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
    {
by Robert Kozak   April 08, 2010 @ 6:04pm
288 Views
no comments
 
C#
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
by Glenn Block   March 17, 2010 @ 9:32am
Tags: Dynamic, MEF
531 Views
no comments
 
C#
public interface IRuleMetadata
{
    [DefaultValue(0)]
    int ExecutionOrder { get; }
}
 
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class RuleAttribute : ExportAttribute, IRuleMetadata
{
    public RuleAttribute(int executionOrder)
by TheCodeJunkie   February 13, 2010 @ 3:30pm
Tags: MEF
749 Views
no comments
 
C#
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 }))
by TheCodeJunkie   February 08, 2010 @ 2:38pm
Tags: MEF
249 Views
no comments
 
C#
public class ConventionPart<T> : IPartImportsSatisfiedNotification
{
    /// <summary>
    /// Initializes a new instance of the <see cref="ConventionPart{T}"/> class.
    /// </summary>
    public ConventionPart()
    {
    }
 
    [ImportMany]
by TheCodeJunkie   February 07, 2010 @ 3:14pm
Tags: MEF
341 Views
no comments
 
C#
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)
by Glenn Block   February 07, 2010 @ 3:07pm
Tags: MEF
480 Views
no comments
 
C#
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)
by bnaya   January 29, 2010 @ 4:10am
933 Views
no comments
 
C#
// 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
  }
by Glenn Block   January 26, 2010 @ 6:34pm
Tags: MEF
593 Views
no comments
 
C#
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);
by bnaya   January 15, 2010 @ 1:17am
685 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate