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

Mugen Injection [Special parameters]

All methods to resolve accepts special-parameters. Why do they need, sometimes we need to pass some information and we do not want to create another class for the description parameter. In this case you can use special-parameters.
This code shows how it works:

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

            .ToMethod<IRepository>(context =>
                                        if (context.SpecialParameters.ContainsKey("fake"))
                                            return new FakeRepository();
                                        return new Repository();
_injector.Get<IRepository>(new Dictionary<string, object>() {{"fake", true}});
It also used in extensions for MugenInjection.

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