In Generic Adapter pattern or in Adapter pattern when adapter implementation is not available for customization, developer may still want to react on insertion, update and deletion of his objects. To cover that IAxDbObjectEvents interface was introduced in AxCMS.net 9.2.0.
IAxDbObjectEvents interface represents methods:
void OnBeforeInsert();
void OnAfterInsert();
void OnBeforeUpdate();
void OnAfterUpdate();
void OnBeforeDelete();
void OnAfterDelete();
which are triggered within AxDbBaseAdapter before/after insert/update/delete operations.
To react on events implement IAxDbObjectEvents interface in your IAxDbObject implementation.
Below is an example of extended AxLabel which implements IAxDbObjectEvents interface (it will simply log before/after actions for code presentation purposes):
[OverridesAxLabel] public class SampleLabel : AxLabel, IAxDbObjectEvents { #region IAxDbObjectEvents Members public void OnAfterDelete() { new SamplePublishAction(this, "OnAfterDelete").Log(); } public void OnAfterInsert() { new SamplePublishAction(this, "OnAfterInsert").Log(); } public void OnAfterUpdate() { new SamplePublishAction(this, "OnAfterUpdate").Log(); } public void OnBeforeDelete() { new SamplePublishAction(this, "OnBeforeDelete").Log(); } public void OnBeforeInsert() { new SamplePublishAction(this, "OnBeforeInsert").Log(); } public void OnBeforeUpdate() { new SamplePublishAction(this, "OnBeforeUpdate").Log(); } #endregion}