Hi Jonny,
I have been playing with your recent business rule changes (CanRunAsAffectedProperty etc) and noticed different behavior if a rule is run as an inner rule.
The standard way of running inner rules, within a gateway rule, bypasses any checks on the RuleContext.ExecuteContext
if (MyCondition)
{
var chainedContext = context.GetChainedContext(thisMyInnerRule);
this.MyInnerRule.Execute(chainedContext);
}
If my inner rule has CanRunAsAffectedProperty = false, I would expect it *not* to run if it is an affected property regardless of it being part of a chain or not. Currently the rule runs if it is an inner rule.
I propose this addition to RuleContext:
public void ExecuteChainedRule(Csla.Rules.IBusinessRule chainedRule)
Which would also require Csla.Rules.BusinessRules.CanRunRule to be changed from private to internal.
And my gateway rule could be written as:
if (MyCondition)
I think this also simplifies the syntax for running chained rules.
Let me know what you think.
Cheers
Peran
Hi Peran,
Great idea and added to Bugtracker: http://www.lhotka.net/cslabugs/edit_bug.aspx?id=1003
I wonder if we should just call the method RuleContext.ExecuteRule
The Using CSLA 4 ebook also call these outer and inner rules but to a programmer it would simply be on or more (inner) rules to be executed from the this rule's context.
What do you think?
Thanks,
'ExecuteRule' method name works for me. I added the word 'Chained' as it was replacing the call to 'Get*Chained*Context'.
Regards
Peran
I renamed the parameter innerRule to go with the documentation.
Great! already checked in to trunk.
Copyright (c) Marimer LLC