You have to override AddInstanceBusinessRules() to call AddInstanceRule().
But I strongly recommend against doing this. There is a major performance and memory consumption cost to using instance rules, and I am still very seriously considering eliminating them from CSLA .NET 4.
jkellywilkerson:Is there an example of how to handle adding custom ValidationRules other than using AddInstanceRule() in the override in the Expert C# 2008 book? Kelly.
No, this is the only way to add per-instance rules currently.
In CSLA 4 I intend to do some pretty substantial changes to the business rules subsystem - something for discussion on its own thread later.
fsl:Thank you for the quick reply.. I'm now overriding AddInstanceBusinessRules() and rules using methods defined in the enclosing class are executed. But not rules using delegates that are passed to the instance.. I'm wondering why this is the case..
Any external rules would need to be public in scope, and would need to remain in scope through the life of the app. In other words, they'd need to be static, or be methods off a singleton or something.
At least that's my recollection. I haven't looked at or used instance rules since 2005, so my memory of the details could be a little fuzzy.
Copyright (c) Marimer LLC