「管理者がこのインスタンスを注入する領域内のコントローラーに IService を注入するとき」というバインディングを作成する方法はありますか?
Admin には、同じサービスを使用する可能性のある多数のコントローラーがあります。コントローラーごとにバインディングを作成することもできますが、別のコントローラーが同じサービスで導入される可能性があり、開発者は管理者 (他のエリアまたはエリア外とは異なるサービス実装のセットを使用する) 用に特別に接続するのを忘れる可能性があります。
// this is the default
kernel.Bind<ICategorizationRepository<DirectoryCategory>>().To<CachedJsonCategorizationProvider<DirectoryCategory>>().InRequestScope();
// Admin bindings use noncaching repositories
kernel.Bind<ICategorizationRepository<DirectoryCategory>>().To<JsonCategorizationProvider<DirectoryCategory>>().WhenInjectedInto<Areas.Admin.Controllers.DirectoryCategorizationController>().InRequestScope();
kernel.Bind<ICategorizationRepository<DirectoryCategory>>().To<JsonCategorizationProvider<DirectoryCategory>>().WhenInjectedInto<Areas.Admin.Controllers.DirectoryEntryController>().InRequestScope();
// .. new controller that uses ICategorizationRepo might be created but the developer forgets to wire it up to the non caching repository - so the default one will be used, which is undesirable
私が言いたいのは、管理領域内の何かに注入するときは、これを使用してください...