Ninject看起来很棒,所以我想在我的项目中使用它.不幸的是,我仍在努力做最琐碎的约束.[Inject]属性编译得很好,但编译器找不到"Bind"命令:
using System;
using Ninject.Core;
using Ninject.Core.Binding;
namespace NinjectTest
{
public interface IFoo
{
void DoSomething();
}
public class Foo : IFoo
{
public void DoSomething()
{
throw new NotImplementedException();
}
}
public class Bar
{
[Inject] private IFoo theFoo;
public Bar()
{
Bind<IFoo>().To<Foo>(); //Compiler Error: "The name 'Bind' does not exist in the current context"
}
}
}
Run Code Online (Sandbox Code Playgroud)
这可能会出错?