Skip to content

Extending the syntax

Remo Gloor edited this page Feb 23, 2012 · 7 revisions

The implementation of the XML extension is highly extendable so that other Ninject extension can hook into to add xml configuration for themselves. This chapter describes how to do this integration.

General information

All the extensions are done by adding new Ninject components to the kernel components. Therefore create a new Ninject Module and add the component as shown in the code below:

public class MyModule : NinjectModule
{
    public override void Load()
    {
        Kernel.Components.Add();
    }
}

Adding a new scope type

New scope types can be added by implementing the IScopeHandler interface as shown by the code blow:

   
public class SingletonScopeHandler : NinjectComponent, IScopeHandler
{
    public string ScopeName
    {
        get
        {
            return "singleton";
        }
    }

    public void SetScope(IBindingInSyntax syntax)
    {
        syntax.InSingletonScope();
    }
}
Clone this wiki locally