Replacing standard IDO processing with event handlers

By adding event handlers, not only can you perform additional logic when a particular event fires, but, in the case of PreUpdateCollection and PreLoadCollection, you can also completely replace the default framework implementation by constructing your own response and setting that in the IDOEventArgs.ResponsePayload field. This example shows how this is done for an UpdateCollection request:

private void HandlePreUpdateCollection(object sender, IDOEventArgs args) 
{ 
   // Get the original request: 
   UpdateCollectionRequestData updateRequest; 
   UpdateCollectionResponseData updateResponse; 
   updateRequest = (UpdateCollectionRequestData)args.RequestPayload; 
   updateResponse = new UpdateCollectionResponseData(updateRequest); 
   // Process items in the request, filling in the response... 
   // Override the standard processing, returning my 
   // custom response instead: 
   args.ResponsePayload = updateResponse; 
}