Hi,
I was wondering if the Csla framework made it possible for BOs (classes that inherint from
BusinessBase<T>) to validate objects contained within them, for example
I have a Customer class that contains an AddressInfo object. This object simply contains fields and properties (address, city, region etc.) so that it can be used by many different classes, Customer being one of them.
Now, as far as I know, validating properties can only be done on the BO itself. Same thing I think with authorization.
Is there a way to validate/authorize objects contained within the framework's business objects?
In addition, are there there going to be any issues with databinding those composed objects?
Thanks,
Ben
In CSLA 1.x a user contributed some code to allow a given BO to validate all contained BOs and their contained BOs and on down the chain.
I posted a version of this code for CSLA 2.x a few months back.
The idea is that this allows you to do a few things:
1. Skip the override for IsDirty.
2. Get a list of all broken rules for a top level BO and all its contained BOs.
Search the forum for sample code.
It may be simpler to just do the overrides for now though.
Joe
I see.
So, my Address class has to be a BO too. Well, that's a bit of an overkill for such a simple class.
I might have lots of classes like this in my app, so turning each and every one of them into a BO might have some overhead to the application.
Wouldn't it be much simpler if ValidationRules class defined an overload for AddRule() that accepted, in addition, an object to perform the validations upon? I saw the code for the ValidationRules class and I think that the target is just a System.Object instance, not a Csla framework BO, making any object viable candidate for validation. So that means that the ValidationRules class would simply maintain a collection of objects to validate and their corresponding properties, isn't that so? In addition, this way, the BO gets a fine grained control as to which properties to validate and every BO can implement it as they see fit.
Ben
NoviceCoder:So, my Address class has to be a BO too. Well, that's a bit of an overkill for such a simple class.
NoviceCoder:I might have lots of classes like this in my app, so turning each and every one of them into a BO might have some overhead to the application.
NoviceCoder:Wouldn't it be much simpler if ValidationRules class defined an overload for AddRule() that accepted, in addition, an object to perform the validations upon?
NoviceCoder:I saw the code for the ValidationRules class and I think that the target is just a System.Object instance, not a Csla framework BO, making any object viable candidate for validation. So that means that the ValidationRules class would simply maintain a collection of objects to validate and their corresponding properties, isn't that so? In addition, this way, the BO gets a fine grained control as to which properties to validate and every BO can implement it as they see fit.
Copyright (c) Marimer LLC