Any case study for New Concepts in CSLA.Net 2.1

Any case study for New Concepts in CSLA.Net 2.1

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


jason2000 posted on Monday, September 04, 2006

there are some new concepts in  CSLA.Net 2.1,such as
"per type Validation rules","Instance Validation Rules","per type Authorization  rules","Instance Authorization rules", seem very useful,but the sample project ProjectTracker covered  few of these,could someone show me some case study in these concepts?

xal replied on Monday, September 04, 2006

Jason,
Instance Validation / Authorization rules is what we've had all along. That means:

An object is instanced, a method is called so that you can load the rules, you create instances of validation rules that will be specific to that object.
When you make another instance of the same type, the process is repeated exactly like that.

With the new shared V / A rules this is what happens:

An object of type XYZ is instanced for the first time. The AddBusinessRules method is called so that you can load the rules and, in there, you create instances of validation rules that will apply to ALL objects of the same type.
When you make another instance of the same type, the AddBusinessRules method never gets called, because the rules are already loaded for that type.

When using Shared rules, make sure you define your rule methods as static/shared. You must use the target parameter of the rule method to run the validation. Here's a sample of how you can use all the latest to validate something:

Shared Validation Rule Sample

Andrés

Copyright (c) Marimer LLC