Ninject.Web.Common.OwinHost3.3.0如何使用?

How to use Ninject.Web.Common.OwinHost 3.3.0?

谁能告诉我Ninject.Web.Common.OwinHost?我正在使用这本手册 https://github.com/ninject/Ninject.Web.Common/wiki/Setting-up-a-OWIN-WebApi-application,但看起来它已经过时了,因为 UseNinjectWebApi 方法不存在。

我正在尝试这样做:

    public void Configuration(IAppBuilder appBuilder)
    {
        // Configure Web API for self-host. 
        var config = new HttpConfiguration();

        config.MapHttpAttributeRoutes();
        WebServiceConfig.ConfigureRoutes(appBuilder);

        appBuilder.UseNinjectMiddleware(CreateKernel);
        appBuilder.UseWebApi(config);
    }

    private static StandardKernel CreateKernel()
    {
        var kernel = new StandardKernel();
        kernel.Load(Assembly.GetExecutingAssembly());
        kernel.Bind<IPropertyRepository>().To<PropertyRepository>().InSingletonScope();

        return kernel;
    }

但是当我调用 API 控制器方法时,我收到一条消息,提示默认构造函数不存在。

public class PropertyController : ApiController
{
    private readonly IPropertyRepository _propertyRepository;

    public PropertyController(IPropertyRepository propertyRepository)
    {
        _propertyRepository = propertyRepository;
    }

    [Route("properties")]
    [HttpPost]
    [LoggerTrace]
    public IHttpActionResult AddProperty([FromBody] PropertyDto propertyDto)
    {
        return Ok();
    }
}

手册https://github.com/ninject/Ninject.Web.Common/wiki/Setting-up-a-OWIN-WebApi-application是实际的。这是我只安装了 Ninject.Web.Common 包,并且有必要安装额外的 Ninject.Web.WebApi 包,其中包含 UseNinjectWebApi 方法。