【发布时间】:2014-04-09 00:47:35
【问题描述】:
我想知道是否有基于约定的方法在 Autofac 中注册以下内容:
builder.RegisterType<BatchDocumentRepository>()
.As<IRepository<BatchDocument, IEnumerable<BatchDocument>, int>>();
builder.RegisterType<BatchRepository>()
.As<IRepository<Batch, IEnumerable<Batch>, int>>();
builder.RegisterType<DeploymentReleaseRepository>()
.As<IRepository<DeploymentRelease, IEnumerable<DeploymentRelease>, int>>();
builder.RegisterType<DeploymentRepository>()
.As<IRepository<Deployment, IEnumerable<Deployment>, int>>();
上面的工作正常,但我只是想知道是否有一种更清洁、更少重复的方法。我看过这个帖子:Resolving Generic Interface with Autofac,但情况并不完全相同。
谢谢!
【问题讨论】: