这是我的控制器构造函数:
public PostCategoryController(ICategorizationRepository<PostCategory> categorizationRepository,
IContentRepository<Post> repository, PostUtilityService postUtilityService)
{
_repository = repository;
_categorizationRepository = categorizationRepository;
_postUtilityService = postUtilityService;
}
如何使用Autofac注册PostUtilityService
的实现?这个服务没有接口,它只是一个执行某些操作的类。
我想使用最简单或最佳性能的Register
方法或重载。
答案 0 :(得分:1)
使用AsSelf
扩展方法。
builder.RegisterType<PostUtilityService>().AsSelf();