我有IRepository
为大量类IRepository<User>
, IRepository<Customer>
等。是否有可能在单位这样注册但对于所有对象,或我必须写手动100注册。
container.RegisterType<IRepository<User>, Repository<User>>()
No you don't. You can register open generics too.
container.RegisterType(typeof(IRepository<>), typeof(Repository<>));
Unity will close the generics for you.
我从未使用过Unity,但是在Ninject的世界中,您只需注册一次依赖项。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.