Could someone expand upon the directions Halil Kalkan (@hikalkan) provided here: https://github.com/volosoft/castle-windsor-ms-adapter
ORIGINAL - works using standard Microsoft DI
public void ConfigureServices(IServiceCollection services)
{
services.AddAutoMapper();
services.AddMvc();
services.AddApiVersioning();
services.AddDbContextPool<CIDMSContext>(options => options.UseSqlServer(""));
services.AddScoped<IBuildingRepository, BuildingRepository>();
services.AddScoped<IComponentRepository, ComponentRepository>();
}
NEW - does not work. trying to use Castle.Windsor.MsDependencyInjection
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddAutoMapper();
services.AddMvc();
services.AddApiVersioning();
services.AddDbContextPool<CIDMSContext>(options => options.UseSqlServer(""));
//services.AddScoped<IBuildingRepository, BuildingRepository>();
//services.AddScoped<IComponentRepository, ComponentRepository>();
return WindsorRegistrationHelper.CreateServiceProvider(
new WindsorContainer(), services);
}
I am getting the error:
Unable to resolve service for type '...Repositories.Buildings.IBuildingRepository' while attempting to activate ...Controllers.BuildingController'
My ultimate goal is to not have to DI every single repository that I ever create. I would like Castle Windsor to DI it by convention. If there are other options to doing this for .Net Core 2.0 then I am open to those options as well.
I am using Visual Studio 15.4.1 .Net Core 2.0 API project.