Microsoft   |   patterns & practices   |   Developer Network   |   Enterprise Library   |   Acceptance Testing Guide   |   Personal Site

DIAB is now Unity - Grigori Melnik: Thoughts on Agile Software Engineering and Beyond - Site Home - MSDN Blogs

DIAB is now Unity

DIAB is now Unity

  • Comments 19

First of all, we finally came up with a name for the DI container we are building. A drum roll, please… We’ve decided to call it “Unity” as a container that epitomizes a quality of one (system) being, comprising, or consisting of a number (of parts/components). It may not be as descriptive as other blocks but it fits with our vision. We also wanted to distinguish it from other application blocks.

A short description of Unity is a lightweight, extensible dependency injection container.

Unity will provide mechanisms for building instances of objects, which may contain other dependent object instances.

Unity will expose Register methods that support configuring the container with mappings and objects (including singleton instances), and Get methods to return instances of built objects that contain any dependent objects. Note we have purposefully designed the API to support the “fluent interface” pattern. Here’s a preview of the fundamental features of the Unity API, these are very tentative as we are still working on the semantics:

public class UnityContainer : IDisposable {

// getting objects

public T Get<T>(string key){}

public IEnumerable<T> GetAll<T>(){}

// type mapping

public UnityContainer Register<TFrom, TTo>(string key) where TTo : TFrom {}

// singleton support

public UnityContainer SetSingleton<T>(string key) {}

// support for registering existing objects

public UnityContainer RegisterInstance<T>(T existing, string key, bool overload) {}

// running existing objects through the container

public T BuildUp<T>(T existing, string key){}

}

There are also overloads for non-generics.

So, a typical usage scenario will be:

UnityContainer container = new UnityContainer()

                  .Register<ILogger, TraceLogger>()

                  .Register<ISomething, Something>()
                  .Register<ISomethingElse, SomethingElse>();

container.Get<ISomething>();

As mentioned in our previous postings, Unity will be released in two forms - standalone container and as a part of Enterprise Library 4, with the existing blocks refactored to take advantage of Unity.

Unity will support extensibility via the ContainerExtension mechanism to allow third parties to add support for other on-demand features at runtime, such as event broker.

 

Comments
  • If you&#39;ve been following Grigori Melnik&#39;s blog , you&#39;ll know a bit about Unity , the new

  • As many people who read this would know, I'm a big fan of IoC containers, more in particular Castle Windsor

  • As many people who read this would know, I'm a big fan of IoC containers, more in particular Castle Windsor

  • Od kilku miesięcy nic tu nie pisałem (oczywiście poza poprzednim nieplanowanym wpisem ). Jak łatwo się

Page 2 of 2 (19 items) 12
Leave a Comment
  • Please add 3 and 7 and type the answer here:
  • Post