Managed Extensibility Framework

Download .net eBook


One of MEF's big advantages over other technologies that support the inversion-of-control pattern is that it supports resolving dependencies that are not known at design-time, without needing much (if any) configuration.

All examples require a reference to the System.ComponentModel.Composition assembly.

Also, all the (Basic) examples use these as their sample business objects:

using System.Collections.ObjectModel;

namespace Demo
    public sealed class User
        public User(int id, string name)
            this.Id = id;
            this.Name = name;

        public int Id { get; }
        public string Name { get; }
        public override string ToString() => $"User[Id: {this.Id}, Name={this.Name}]";

    public interface IUserProvider
        ReadOnlyCollection<User> GetAllUsers();

Related Examples


79 Contributors: 3
Friday, November 4, 2016
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial:

Download eBook