Home

Vici CoolStorage - Documentation - Events

Events

CoolStorage allows you to attach an event to almost any operation performed on the CoolStorage objects. You can attach events to specific instances of objects, or on any CoolStorage-derived class.

The following events can be intercepted:

  • Reading Before an object is read from the database
  • Read After an object is read from the database
  • Saving Before an object is saved to the database (create and update)
  • Saved After an object is saved to the database (created and updated)
  • Updating Before an object is updated in the database
  • Updated After an object is updated in the database
  • Creating Before an object is created in the database
  • Created After an object is created in the database
  • Deleting Before an object is deleted from the database
  • Deleted After an object is deleted from the database

To attach an event handler to a single object, you attach the event handler to the object's "ObjectXXXXX" event, where XXXXX is the name of the event, as listed above.

To attach an event handler to any instance of an object of a specific type, you attach the event handler to the event handler "AnyObjectXXXXX", declared at the class level as a static event.

For example:

Customer customer = Customer.New();

// attach an event to a single object. The event will be fired after 
// the object was created and stored in the database
customer.ObjectCreated += MyCustomerCreatedEventHandler;

// attach an event to the Order class. The event will be fired after
// ANY object of class Order is deleted from the database
Order.AnyObjectDeleted += MyDeletedOrderEventHandler;