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

Mugen Injection [Activation (IActivator)]

To activate IBinding used the IActivator interface, a list of all available types of IActivator:

  • ReflectionActivator - use reflection to activate objects.
  • EmitActivator - use emit to activate objects.
  • ExpressionActivator - use expression trees to activate objects.
You can easily extend this list by implementing the interface IActivator.
When you register service, you can specify the IActivator that will use to create service, this code shows how it work:
// Create your MugenInjector.
var injector = new MugenInjector();
injector.Bind<Alpha>().ToSelf().UseEmitActivator();
injector.Bind<Alpha>().ToSelf().UseReflectionActivator();
injector.Bind<Alpha>().ToSelf().UseExpressionActivator();
injector.Bind<Alpha>().ToSelf().UseCustomActivator(new YourCustomActivator());
You can also make some IActivator as default for all bindings:
// Create your MugenInjector.
_injector = new MugenInjector();
_injector.Settings.DefaultActivatorFactory = () => new ExpressionActivator();

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]