miércoles, julio 19, 2006

DataEventArgs

Despues de publicar mi post anterior, me di cuenta de que la clase DataEventArgs<T> no forma parte del .NET Framwork. Nosotros usamos Mobile CAB y resulta que la clase pertenece a este framework. Muy seguramente el CAB para Windows tambien lo use, pero bueno si ustedes estan programando para Web o simplemente no usan CAB, pueden usar la siguiente clase en su proyecto. Es tan sencillo el código que toma lo mismo hacerla que haber hecho algún otro EventArgs.

using System;

namespace Microsoft.Practices.Mobile.CompositeUI.Utility

{

/// <summary>

/// Generic arguments class to pass to event handlers that need to receive data.

/// </summary>

/// <typeparam name="TData">The type of data to pass.</typeparam>

public class DataEventArgs<TData> : EventArgs

{

TData data;

/// <summary>

/// Initializes the DataEventArgs class.

/// </summary>

/// <param name="data">Information related to the event.</param>

/// <exception cref="ArgumentNullException">The data is null.</exception>

public DataEventArgs(TData data)

{

if (data == null)

{

throw new ArgumentNullException("data");

}

this.data = data;

}

/// <summary>

/// Gets the information related to the event.

/// </summary>

public TData Data

{

get { return data; }

}

/// <summary>

/// Provides a string representation of the argument data.

/// </summary>

public override string ToString()

{

return data.ToString();

}

}

}

No hay comentarios.: