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

Mugen Injection [Resolving unregistered type]

The MugenInjection supports to resolve unregistered type. To resolve unregistered type you can write behavior.
This code shows how it works:

public class UnregisteredTypeResolver : IResolveUnregisteredTypeBehavior
{
    #region Implementation of IResolveUnregisteredTypeBehavior

    public bool Resolve(IBindingContext bindingContext, out object result)
    {
        if (bindingContext.Service == typeof (string))
        {
            result = "empty";
            return true;
        }
        result = null;
        return false;
    }

    #endregion
}

// Create your MugenInjector.
_injector = new MugenInjector();
_injector.Components
    .Get<IBehaviorManagerComponent>()
    .Add<IResolveUnregisteredTypeBehavior>(new UnregisteredTypeResolver());

//s equals to "empty"
var s = _injector.Get<string>();

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]