RuleArgs Question

RuleArgs Question

Old forum URL: forums.lhotka.net/forums/t/1291.aspx


JoeFallon1 posted on Wednesday, September 20, 2006

When I build a rule if I want to pass an extra value like maxLength I can derive from RuleArgs and add the extra Property. That is pretty clear.

But what if I want to use a value of the BO instance that can change over time instead of a constant like maxLength. What if I have a Property in the BO named VariableLength and I pass that in as the rulearg parameter? Will the rule be created once and that value be treated as a constant? Or will the rule "look up" the current value of that field in the BO and use it instead? I have a feeling it won;t do that without using reflection - so maybe I should be passing the fieldname to look up instead of the current value.

Comments?

 

RockfordLhotka replied on Wednesday, September 20, 2006

You could pass the property or field name that would contain the value in question, and as you suggest, use reflection to access it.

Or you could put the rule implementation directly in your business class and just access the field directly.

JoeFallon1 replied on Thursday, September 21, 2006

Rocky,

Thanks for the feedback. I was "thinking out loud" when I posted and came to the conclusion that I would need to pass the PropertyName in RuleArgs and then access it through reflection.

The main reason for doing it that way (instead of building the rule into the BO) is that I am trying to centralize common rules for my BOs. This is working out very well so far. I like the idea of writing the rule once and calling it from many places.

When I get to the point where a rule is unique to a given BO I will probaly embed the method in it the BO so it can access any values it needs directly.

Joe

 

Copyright (c) Marimer LLC