Events

This topic covers the specific events exposed by the PersistenceManager.

PersistenceError

The PersistenceError event is raised when an error occurs during the process of persisting or restoring. The PersistenceError event handler receives two arguments:

  • The sender argument contains the PersistenceManager object. This argument is of type object, but can be cast to the PersistenceManager type.

  • A PersistenceErrorEventArgs object. Using this object you can find the raised Exception, the Name of the property that caused the error and the Path to the property that caused the exception.

PropertyPersisting

The PropertyPersisting event is raised before a property starts persisting. The PropertyPersisting event handler receives two arguments:

  • The sender argument contains the PersistenceManager object. This argument is of type object, but can be cast to the PersistenceManager type.

  • A PersistingPropertyEventArgs object. Using this object you can find the Name and the__Path__ of the property that is about to be persisted. You can cancel the persisting of the property by setting the Cancel property to True.

PropertyPersisted

The PropertyPersisted event is raised when a property has been persisted. The PropertyPersisted event handler receives two arguments:

  • The sender argument contains the PersistenceManager object. This argument is of type object, but can be cast to the PersistenceManager type.

  • A PersistenceEventArgs object. Using this object you can find the the Name of the persisted property and its Path.

PropertyPersistenceCompleted

The PropertyPersistenceCompleted event is raised when all properties have been persisted. The PropertyPersistenceCompleted event handler receives two arguments:

  • The sender argument contains the PersistenceManager object. This argument is of type object, but can be cast to the PersistenceManager type.

  • An EventArgs object.

PropertyRestoring

The PropertyRestoring event is raised before a property is restored. The PropertyRestoring event handler receives two arguments:

  • The sender argument contains the PersistenceManager object. This argument is of type object, but can be cast to the PersistenceManager type.

  • A RestoringPropertyEventArgs object. Using this object you can find the the Name and the Path of the property that is about to be restored. You can cancel the restoring of the property by setting the Cancel property to True.

PropertyRestored

The PropertyRestored event is raised when a property has been restored. The PropertyRestored event handler receives two arguments:

  • The sender argument contains the PersistenceManager object. This argument is of type object, but can be cast to the PersistenceManager type.

  • A PersistenceEventArgs object. Using this object you can find the the Name of the persisted property and its Path.

PropertyRestoringCompleted

The PropertyRestoringCompleted event is raised when all properties have been restored. The PropertyRestoringCompleted event handler receives two arguments:

  • The sender argument contains the PersistenceManager object. This argument is of type object, but can be cast to the PersistenceManager type.

  • A EventArgs object.

The PropertyPersisted/PropertyRestored events of collection properties will be raised only after all their items' properties are persisted/restored.

In this article