it may be easy, but an internet search already gives me a headache
here is the problem:
interface IValidator { void Validate(object obj); } public class ValidatorA : IValidator { public void Validate(object obj) { } } public class ValidatorB : IValidator { public void Validate(object obj) { } } interface IClassA { } interface IClassB { } public class MyBaseClass { protected IValidator validator; public void Validate() { validator.Validate(this); } } public class ClassA : MyBaseClass, IClassA {
Any idea?
EDIT
I registered ValidatorA and ValidatorB with Named , now the problem is how Castle Windsor can correctly insert this validator into ClassA and ClassB , is there any way to do this? or is there a better solution?
If someone thinks my class design is wrong, I open for any advice. So far I think this is correct. Yes, the validator has a specific configuration for a specific class. but there are reasons why he abstracts:
- Validator is a complex object that once needs to connect to the database, so I MUST pass the interface instead of implementing it to the constructor to justify unit testing.
- It is not possible to use a different interface for any of Validator, because the only method I used is
Validate - I think that
MyBaseClass.Validate() generic template template right?
c # castle-windsor
ktutnik
source share