简体   繁体   中英

Ninject 3.0.1.10 + factory extension there is not tofactory method

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

您需要添加命名空间引用:

using Ninject.Extensions.Factory;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM