Iam creating an ASP.NET Web API project with code that used to work in other solution.
I installed Ninject and Ninject.Extensions.ChildKernel packages but they are not found in the file : NinjectResolver.cs
Code :
using Ninject;
using Ninject.Extensions.ChildKernel;
using Assurance.Abstract;
using Assurance.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http.Dependencies;
namespace Assurance.API
{
public class NinjectResolver : IDependencyResolver
{
private IKernel kernel;
public NinjectResolver()
: this(new StandardKernel())
{
}
public NinjectResolver(IKernel ninjectKernel, bool scope = false)
{
kernel = ninjectKernel;
if (!scope)
{
AddBindings(kernel);
}
}
public IDependencyScope BeginScope()
{
return new NinjectResolver(AddRequestBindings(new ChildKernel(kernel)), true);
}
public object GetService(Type serviceType)
{
return kernel.TryGet(serviceType);
}
public IEnumerable<object> GetServices(Type serviceType)
{
return kernel.GetAll(serviceType);
}
public void Dispose()
{
}
private void AddBindings(IKernel kernel)
{
// singleton and transient bindings go here
}
private IKernel AddRequestBindings(IKernel kernel)
{
kernel.Bind(typeof(IClientRepository<>)).To(typeof(ClientRepository<>)).InSingletonScope();
kernel.Bind<IClientService>().To<ClientService>().InSingletonScope();
return kernel;
}
}
}
Ps : the code used to work and I installed succefully the packages bit it always not building.
What Can I do ?