Shared Authorization and Validation rules problem with inheritance

Shared Authorization and Validation rules problem with inheritance

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


burmajam posted on Friday, March 16, 2007

There's a problem with shared authorization and validation rules when there's inheritance, because shared rules are specific to particular type in wich they are defined. One solution is to call base.AddBusinessRules() and base.AddAuthorizationRules() from within derived classes. The other solution could be inside the framework, when checking shared rules to check recursive until it reaches Csla.BusinessBase<T> class.

Does someone have some other workaround or idea?

ajj3085 replied on Friday, March 16, 2007

I think base.AddBusinessRules is the appropriate way to go.  There may be times when you don't want to call the base, and having the framework check rules would not let you acomplish that.

burmajam replied on Friday, March 16, 2007

You are quite right about situations where someone wouldn't want to inherit rules, but framework shoud supply protected boolean field for this purpose with default true value.

ajj3085 replied on Friday, March 16, 2007

Why?  Whenever you inherit and override a method, its up to you to call the base method if you still want the base behavior.

burmajam replied on Friday, March 16, 2007

The only reason is memory consumption. Rules are duplicated winth base.xyz call. I'm not sure though if it is worth of changing framework. I guess not

xal replied on Friday, March 16, 2007

One of the first drafts of 2.1 did have this "processing" to look for rules in your base classes and add them to the derived one. The reason for that was that the rules where being added in the shared cctor (which led to other issues). The model was later changed to this one, in which you're supposed to call base.AddBusinessRules().

Andrés

Copyright (c) Marimer LLC