Adding a TAG property to Csla.Validation.RuleArgs and Csla.Validation.BrokenRule

Adding a TAG property to Csla.Validation.RuleArgs and Csla.Validation.BrokenRule

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


yanivabo posted on Tuesday, April 20, 2010

Hello,
My name is yaniv and I’m a new user to the CSLA framework and so far it's look very promising, I read the book and have the videos (Silverlight and framework). I’m using CSLA 3.8.2

I have one problem, when a business object is not valid I need to get not only the error description but also Error Code. Is there any way to get that is the current CSLA frame work?

I need this feature because some of the objects are exposed (not directly) using a web service for other companies programmers to interact. if they transfer invalid data (didn’t send a required filed for exempla) I need to return an error. It is a good practice to return Error Code number + description for service errors. Save a lot of time in developing.

Is it possible to add to the Csla.Validation.RuleArgs and Csla.Validation.BrokenRule a TAG property type of object that can be used to transfer any additional info on the broken rule?

ajj3085 replied on Tuesday, April 20, 2010

You could use DecoratedRuleArgs to add in an error code.

yanivabo replied on Tuesday, April 20, 2010

If I use DecoratedRuleArgs to add a custom argument as Error Code, how can I get the error code from the

object  BrokenRulesCollection -> BrokenRule?

ajj3085 replied on Tuesday, April 20, 2010

The BrokenRule's ToString will return a Uri, which will have the ErrorCode dictionary value included, which you should be able to parse with the RuleDescription class to get the value.

Thinking about this though, you'll probably need a custom RuleArgs subclass per error condition, since the same RuleArgs is reused with each running of the rule.

Copyright (c) Marimer LLC