Question

I use Nineject for .NET ioc container. I would like to use the factory method, but I can not. There is not .ToFactory method.

I added to project the Ninject.Extensions.Factory extension for Ninejct for .NET 3.0.1.10 and I added the CastleCore 3.0 to the project then I would like to invoke the ToFactory method, I do not see it.

There are, ToMethod, ToProvider method, but there is not ToFactory

I tried on this code:

public class Foo
{
    private IBarFactroy barFactroy;
    public Foo(IBarFactory barFactory)
    {
        this.barFactory = barFactory;
    }

    public void Do()
    {
        var bar = this.barFactroy.CreateBar();
    }
}

public interface IBarFactory
{
    Bar CreateBar();
}

in this way

kernel.Bind<IBarFactory>().ToFactory();

Why am I not able to invoke the ToFactory method?

I see the NuGet installed the ninject 3.0.2 prelease ninject for .net

Was it helpful?

Solution

You need to add a namespace reference:

using Ninject.Extensions.Factory;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top