About .NET, ASP.NET, MVC, C#, WPF, WCF and everything related to .NET and more.

Mugen Injection [Keyed bindings]

The MugenInjector supports register binding with key. Keys are not necessarily unique; multiple bindings for a given service may be registered with the same key, this code shows how it work:

public class Alpha { }
public class Beta : Alpha { }
public class Bravo : Beta { }

public enum KeyEnum

// Create your MugenInjector.
_injector = new MugenInjector();


var alpha = _injector.Get<Alpha>(KeyEnum.Alpha);//Instance of Alpha.
var beta = _injector.Get<Alpha>(KeyEnum.Beta);//Instance of Beta.
var bravo = _injector.Get<Alpha>(KeyEnum.Bravo);//Instance of Bravo.
This code shows how register multiple bindings with the same key:
// Create your MugenInjector.
_injector = new MugenInjector();


var list = _injector.Get<IList<Alpha>>(KeyEnum.Alpha);
var enumerable = _injector.GetAll<Alpha>(KeyEnum.Alpha);

Leave a Reply
* Bullet List
** Bullet List 2
# Number List
## Number List 2
{"Do not apply formatting"}
{code:language} code here {code:language}.
Supports: aspx c#, c#, c++, html, sql, xml