I know this has been asked before, but I can't find any resolution: Using Enterprise Library Configuration in VS08 to use Policy Injection to inject Validation Rules into Types.
Using a VERY simple example: Interface IPerson, User : IPerson, Tester : IPerson
I'd like a policy to inject all types (User, Tester) that imlpement an interface (IPerson) with a simple validation (range validation on a member for example)
The injection "works" - since I can validate as follows:
results = Validation.Validate<IPerson>(myPerson);
However, this doesn't:
Tester myTester = new Tester();
Validator validator = ValidationFactory.CreateValidator(Tester.GetType());
results = validator.Validate(myTester);
Am I thinking about this all wrong? Should I always be validating with the interface? Basically, I'm looking for the best paractice for imlpementing consistent and repeatable validation across a number of types which implement an interface.
Policy Injection appears to offer this since I can change the rules without requiring a code build.
Any help gratefully received.