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

Mugen Injection [Registering bindings using Expression]

The MugenInjector can accept a lambda expression to be used for creating binding, this code shows hot it work:

public class Bravo : Beta
    public Bravo(Beta beta)


    public Alpha Alpha { get; set; }

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

_injector.Bind<Bravo>().To(context => new Bravo(context.Resolve<Beta>()) { Alpha = new Alpha() });
This code is equivalent to:
            .TakeConstructor(context => new Bravo(context.Resolve<Beta>()))
            .WithPropertyValue(bravo => bravo.Alpha, new Alpha());
The expression not used to create service, it's used only to create binding.

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