ビジネス層には、3 つのサービス インターフェイスが
IUserService IRoleServiceあり、IGroupService
および 1 つのバリデータ インターフェイス IValidator IValidator には 3 つの実装がUserValidatorありRoleValidatorますGroupValidator。
IUserService is implemented by UserService(IValidator userValidator)
IRoleService is implemented by RoleService(IValidator userValidator)
IGroupServiceis implemented by GroupService(IValidator userValidator)
3 つのサービスはすべて、IValidator をコンストラクタ パラメータとして使用します。
Web レイヤーには、コンストラクター パラメーターとして受け取るコントローラー、コンストラクター パラメーターとして受け取るコントローラー、およびコンストラクター パラメーターを受け取るグループ コントローラーが3つありUserControllerます。IUserServiceRoleControllerIRoleServiceIGroupServiceas
私の質問:
roleService にRoleValidatorオブジェクトGroupServiceを取得させ、オブジェクトを取得させるにはどうすればよいですかGroupValidator。
Castle Windsor 3.1を使用しています
windsorContainer.Register(Component.For<IValidator>()
.ImplementedBy<UserValidator>()
.Named("userValidator")
.LifestyleTransient());
windsorContainer.Register(Component.For<IValidator>()
.ImplementedBy<RoleValidator>()
.Named("roleValidator")
.LifestyleTransient());
windsorContainer.Register(Component.For<IValidator>()
.ImplementedBy<GroupValidator>()
.Named("groupValidator")
.LifestyleTransient());
userValidator の登録時に使用IsFallback()しましたが、3 つのサービスすべてが roleValidator オブジェクトを取得します。