Why does ValidationRule use FixedPropertyMemberValueAccessBuilder?

Topics: Validation Application Block
Oct 21, 2015 at 3:05 PM
Why does ValidationRule in the ValidationBlock WPF Integration library use FixedPropertyMemberValueAccessBuilder?
I'm sure there must be a good reason why it doesn't just use the existing ReflectionMemberValueAccessBuilder but I can't figure out what it is.
I ask because I'm thinking about how to make the WPF integration of a property take account of rules (perhaps self-validation rules) that work across more than one property of the containing object. Obviously this will take a bit of work in various places, but the first thing I'm looking at is the need to pass the whole object to the initial call to Validate, where at the moment we pass an ExternalValue and use FixedPropertyMemberValueAccessBuilder to look inside it.
Oct 21, 2015 at 3:33 PM
If the answer is merely to support validating direct values rather than bound values using SourceType and SourcePropertyName then I think I can work around this by only using FixedPropertyMemberValueAccessBuilder when the value isn't bound.
Oct 22, 2015 at 10:51 PM
My hypothesis seems to be correct, I updated ValidationRule to do a switch on whether the thing being validated was a bound property and used ReflectionMemberValueAccessBuilder when it was and things still worked well.
This has allowed me to add in code that takes account of validation that affects the property that the ValidationRule is attached to but that isn't directly attached to that property, such as self-validation code that returns a ValidationError that has the property name as its Key.
Would this last modification be of general use? If so I can submit the code. I'd probably change it first so that it only gets called if a specific property is set on the ValidationRule though as it obviously takes more processing to validate the whole object and then scan for errors that apply to the property than only run validators directly attached to the property.