CustomRules \ No Property Get

Topics: Developer Forum
Apr 19, 2007 at 12:55 PM
Morning Simon,

With regard to custom rules, in some circumstances I would rather the property value is not 'given to me' (i.e. in TargetMemberValue I believe) for a number of possible reasons: -

1. In my case because of limitations or the persistence layer I have to use that sometimes causes an exception to be thrown when trying to obtain the property value. I can get round this issue by way of the type instance that's passed in.
2. There may be some, possibly expensive, processing I may wish to avoid based on some values in my context object or the type instance that's passed in.

Any thoughts on this?

Thanks,

- Andrew
Apr 22, 2007 at 5:35 AM
Edited Apr 22, 2007 at 5:35 AM
Andrew

A couple of points first.

It is with these points in mind that the design of PropertyValidationManager is based.

But moving onto your situation... The only way you can feed in your own property value to CustomRule is to modify the source of that value – PropertyValidationManager. This would be done by adding overloads to the Validate and TryValidate methods so they accept an extra object parameter which would be the value of the property. I do not currently have any plans to refactor PropertyValidationManager in this manner but it would be a relatively small amount of work to create your own PropertyValidationManager with these changes. You would also want to remove the paramterless Validate and TryValidate methods meaning it would not be possible to validate all properties with one method call.

If this is a path you want to go down, and you have trouble creating your own PropertyValidationManager, you can contact me through my profile page http://www.codeplex.com/UserAccount/UserProfile.aspx?UserName=SimonCropp and I can give you some more detailed pointers.