I have posted the third article in the WPF Business Application Series.
You can read Part 3 on Code Project here: Business Object Declarative Programming; How To Implement Object Validation & Logging.
This article covers in great detail declarative programming in the business layer. This library allows for codeless validation of business object, codeless character text case correction and entity log entry creation. The article has a Silverlight video that demonstrates the features of the UI.
One of my goals was to have unified binding exception and validation rule violation reporting. I was able to achieve this without any additional code in the form code behind.
The following are the bullet points of the BusinessEntityBase class that provides much of the functionality.
- Shared and instance rule management, invocation and broken rule reporting. This includes multiple rule-set capabilities.
- Error reporting at the property and object level. Errors can be extracted as either a string or generic list.
- Is dirty tracking.
- Very simplified method for setter’s to call that encapsulates the validation, event raising and property text case logic.
- Audit message creation based on decorated properties. Message can be a string or collection of property name value pairs.
- Message creation for the entire class. Message can be a string or collection of property name value pairs.
- Change notification for all entity properties.
- Changing notification for all entity properties.
- Intelligent change notification for the IDataErrorInfo.Error property. This permits the Error property to be data bound and always be reported correctly in the UI.
- Rich set of overridable methods that provide the deriving classes flexibility in programming business logic if required.
I have tried some innovative and in some cases original coding techniques (if that is even possible) to achieve the results I was looking for.