1

これは私のコントローラーコンストラクターです:

    public PostCategoryController(ICategorizationRepository<PostCategory> categorizationRepository,
                                                         IContentRepository<Post> repository, PostUtilityService postUtilityService)
    {
        _repository = repository;
        _categorizationRepository = categorizationRepository;
        _postUtilityService = postUtilityService;
    }

PostUtilityServiceAutofacに実装を登録するにはどうすればよいですか?このサービスにはインターフェースがなく、いくつかのアクションを実行するクラスにすぎません。

Register最も単純または最高のパフォーマンスの方法またはオーバーロードを使用したいと思います。

4

1 に答える 1

1

AsSelf拡張メソッドを使用します。

builder.RegisterType<PostUtilityService>().AsSelf();
于 2012-08-26T13:35:50.560 に答える