Krzysztof recently announced on his blog that we have begun working on an extensibility framework for .NET..

 

We will blog more details about MEF in the upcoming months, but here are some early details (subject to changes, of course): MEF is a set of features referred in the academic community and in the industry as a Naming and Activation Service (returns an object given a “name”), Dependency Injection (DI) framework, and a Structural Type System (duck typing). These technologies (and other like System.AddIn) together are intended to enable the world of what we call Open and Dynamic Applications, i.e. make it easier and cheaper to build extensible applications and extensions.

[....]

And finally here is some code showing basic scenarios our framework supports:

Creating an Extension Point in an Application:

public class HelloWorld {

  [Import] // import declares what a component needs
  public OutputDevice Output;

  public void SayIt() {
        Output.WriteLine("Hello World");
  }
}

// Extension 
public abstract class OutputDevice {
  void WriteLine(string output){}
}

1. Creating an Extension

[Export(typeof(OutputDevice))] // export declared what a component gives
public class CustomOutput : OutputDevice {
  public void WriteLine(string output) {
    Console.WriteLine(output);
  }
}

 

2. Magic that makes composes (DIs) the application with the extensions.

var domain = new ComponentDomain();
var hello = new HelloWorld();
// of course this can be implicit
domain.AddComponent(hello); 
domain.AddComponent(new CustomOutput());
 
domain.Bind(); // bind matches the needs to gives
hello.SayIt();

We'd love to hear what you think.. please join the discussion on Kry's blog.