The DataObjectBase class is a class that can be used to quickly implement data objects that must support the following requirements:
1) Fully serializable
2) Support property changed notifications
3) Backwards compatibility
4) Error checking
5) Backup & revert
Detailed information
1) Fully serializable
The class is fully serializable and thus can be used in remoting, the System.AddIn namespace (which is implemented via Remoting) and in serialization to disk or any other type of storage.
The object is also clonable, so it is very easy to create a deep-clone copy of the object.
2) Support property changed notifications
The class implements the INotifyPropertyChanged notification. This allows the class to be used in WPF environment, where all the data objects must implement INotifyPropertyChanged in order to let the WPF engine know when a property has changed.
3) Backwards compatibility
The class allows backwards compatibility through the RedirectTypeAttribute. In case that the class cannot deserialize an object correctly, it will switch to "redirect" mode to try and solve any redirected classes.
4) Error checking
The class implements the IDataErrorInfo interface so it can let interested objects know whether it contains errors or not.
5) Backup & revert
The class implements the IEditableObject interface. Therefore, it is very easy to create an initial state when opening the object ina window with a call to the BeginEdit method. When the user wants to save the data, simply call the EndEdit function to remove the backup and continue with the data the user entered. If the changes by the user should be discarded, simply make a call to the CancelEdit method.
Property definitions
Properties are defined in a really easy way (in the same manner that you need to define dependency properties):
///
/// Gets or sets the filename property.
///
public string FileName
{
get { return GetValue(FileNameProperty); }
set { SetValue(FileNameProperty, value); }
}
///
/// Register the property so it is known in the class.
///
public readonly PropertyData FileNameProperty = RegisterProperty("FileName", typeof(string), string.Empty);
Important license information
The license that is inlcuded in this package (license.html) applies to all source files and executables, except for these files:
* CatenaLogic.dll
* CatenaLogic.Windows.dll
They are included for demo purposes only and may not be used in (non-)commercial applications without a written notice from the author (CatenaLogic).
Example application
The example application shows a simple class (that represents an entry in an ini-file) with validation. Of course, the class is much more powerful than shown in the demo application, but it should give you enough information to get a basic understanding of the class.

Important: this article has been updated! A new version is available here!
DataObjectBase.zip (337.36 kb) [Downloads: 117]