Pass object via DataEventArgs?

Topics: CAB & Smart Client Software Factory
Mar 1, 2007 at 3:23 PM
I have an object I want to pass through an event. Do I need to create my own DataeventArgs class inheriting from the standard one? or ???

Thanks.
Rob
Mar 1, 2007 at 3:55 PM
I would suggest you use the EventArgs class in the Infrastructure.Interface
namespace, that one allows you to define your eventhandler with a template
parameter (== the class of the object you want to pass around). See the GlobalBank.BranchSystems.Module.ModuleController in the
BankBranchWorkbench application for an example.
Mar 1, 2007 at 4:40 PM
If it's just a single object, use the EventArgs<T> class in the Infrastructure project. Otherwise, if you need to pass multiple parameters at a time, then you'll need a custom EventArgs class.

Mar 1, 2007 at 4:52 PM
Ok. Worked great. I appreciate your help.

thanks.
Rob
Mar 1, 2007 at 5:37 PM
Hi Rob, you should use DataEventArgs because is a generic class.

Take a look at this piece of code:

[EventPublication("topic://MyApp/UpdateCustomerInfo", PublicationScope.Global)]
public event EventHandler<DataEventArgs<Customer>> UpdateCustomerInfoEvent;
 
protected virtual void OnCustomerInfoUpdate(Customer myCustomer)
{
      if (UpdateCustomerInfoEvent != null)
      {
            UpdateCustomerInfoEvent(this, new DataEventArgs<Customer>(myCustomer));
      }
}

Let me know if this helps,

Ezequiel Jadib
http://staff.southworks.net/blogs/ejadib