一些 IOC 容器具有基于约定的所谓自动连接,例如,IProductRepository 映射到 ProductRepository,而无需您进行任何手动连接。
Ninject 有这种东西吗?
最佳答案
// use Ninject.Extensions.Conventions for convention-based binding
kernel.Scan(scanner =>
{
// look for types in this assembly
scanner.FromCallingAssembly();
// make ISomeType bind to SomeType by default (remove the 'I'!)
scanner.BindWith<DefaultBindingGenerator>();
});
复制自@Pete Montgomery 评论
关于inversion-of-control - Ninject 自动接线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9019122/