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

Mugen Injection [Registering bindings as method delegate]

The MugenInjector can accept a delegate to be used as a service creator, this code shows hot it work:

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

_injector.Bind<Alpha>().ToMethod(GetAlpha);

private static Alpha GetAlpha(IBindingContext bindingContext)
{
    return new Alpha();
}
For generic binding the delegate is as follows:
public delegate T MethodBindingDelegate<out T>(IBindingContext bindingContext);
For non-generic binding the delegate is as follows:
public delegate object MethodBindingDelegate(IBindingContext bindingContext);
It takes IBindingContext and returns an instance of service

Comments
Leave a Reply
*bold*
_italics_
+underline+
* 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
[url:http://www.example.com]