Modern client-server applications manipulate complex graphs of data objects. For example a contract with its positions and optional amendments is represented as a hierarchy of data information. These graphs are transferred from and to the client application. The user views data, edits it and commits the changes to the database through server functions. The patterns commonly found in the literature describe thoroughly how to implement simple data transfer objects DTO, but ignore the complexity of how graphs of objects should efficiently be transmitted between server and client components. The intended audience is software developers interested in using DOG or implementing their own variant.
This package is a copy from the java-pmMDA framework.
Differences between java pmMDA and pmMDA.NET:
Properties of data objects can raise
two events. The changed event is raised if the tagged value
.net-dog-change-event is set to true. The vetoable event
is raised if the tagged value
.net-dog-veto-event is set to
true
.
Java-pmMDA uses the
PropertyChangeSupport
for the property events.
pmMDA.NET uses the
event concept
built-in the .NET framework to define the property events.
pmMDA.NET uses the .NET naming convention for bindable properties. The events are defined
using the PropertyChangedEventHandler
. The argument of the events is of
type PropertyChangedEventArgs
.
Currently these events can not be used for data binding because they doesn't use the EventHandler delegate.
The vetoable events have the suffix "Changing" and are defined using the
PropertyChangingEventHandler
. The argument of the events is of type
PropertyChangingEventArgs
. To cancel the change of the property, set the
Cancel
property to false
. In java pmMDA a PropertyVetoException
would be thrown in that case.
In java-pmMDA there are two methods (addPropertyChangeListener and
addVetoableChangeListener) which allow to connect to every property event. In pmMDA.NET
there are (at maximum) two events for each Property ( PropertyName
Changed
and PropertyName
Changing).
There is an example at the end of this page.
In the .NET framework it is a common behaviour to raise the events from a separate method.
This method name consists of the prefix "On" followed by the event name. It takes the
event arguments as parameters and is protected and virtual.
This pattern allows derived classes to be notified about the events by overriding the
event method witout having to register for events. Also the event methods allow derived
classes to raise the events.
pmMDA.NET defines the event methods and calls them during the change of properties instead of raising the events directly.
Event definition
// ... public class MyDataObject : IDataObject { private string m_name; // ... public event PropertyChangedEventHandler NameChanged; public event PropertyChangingEventHandler NameChanging; // ... public string Name { get { return m_name; } set { PropertyChangingEventArgs e = new PropertyChangingEventArgs(this, "Name", m_name}, value); OnNameChanging(e); if (e.Cancel) { return; } m_name = value; Modified = true; OnNameChanged(new PropertyChangedEventArgs(this, "Name")); } } // ... protected virtual void OnNameChanged(PropertyChangedEventArgs e) { if (NameChanged != null) { NameChanged(this, e); } } protected virtual void OnNameChanging(PropertyChangingEventArgs e) { if (NameChanging != null) { NameChanging(this, e); } } // ... }
Connect to events
void SomeMethod() { MyDataObject myDataObject = new MyDataObject(); myDataObject.NameChanged += new PropertyChangedEventHandler(myDataObject_NameChanged); myDataObject.NameChanging += new PropertyChangingEventHandler(myDataObject_NameChanging); // for other properties // myDataObject.PasswordChanged += new PropertyChangedEventHandler(myDataObject_PasswordChanged); // myDataObject.PasswordChanging += new PropertyChangingEventHandler(myDataObject_PasswordChanging); } private void myDataObject_NameChanged(object sender, PropertyChangedEventArgs e) { // name changed event is raised in this method } private void myDataObject_NameChanging(object sender, PropertyChangingEventArgs e) { // name changing event is raised in this method // e.Cancel = true; // to abort the change of the property. } /* for password property private void myDataObject_PasswordChanged(object sender, PropertyChangedEventArgs e) { // password changed event is raised in this method } private void myDataObject_PasswordChanging(object sender, PropertyChangingEventArgs e) { // password changing event is raised in this method // e.Cancel = true; // to abort the change of the property. }
*/
Currently there are no events for indexed properties
Descriptions for the classes, interfaces and types can be found in the API.