12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using System;
- namespace Wayne.Lib
- {
- /// <summary>
- /// A generic event args holding an argument of some type.
- /// </summary>
- /// <typeparam name="T">The event argument.</typeparam>
- public class EventArgs<T> : EventArgs
- {
- #region Fields
- private T argument;
- #endregion
- #region Construction
- /// <summary>
- /// Construction.
- /// </summary>
- /// <param name="argument">The event argument.</param>
- public EventArgs(T argument)
- {
- this.argument = argument;
- }
- #endregion
- #region Properties
- /// <summary>
- /// The event argument.
- /// </summary>
- public T Argument
- {
- get { return argument; }
- }
- #endregion
- #region Debug methods
- /// <summary>
- /// Presents the class as a string.
- /// </summary>
- /// <returns></returns>
- public override string ToString()
- {
- return string.Format(System.Globalization.CultureInfo.InvariantCulture,
- "EventArgs<{0}>({1})", argument.GetType().Name, argument);
- }
- #endregion
- }
- /// <summary>
- /// A generic event args holding an argument of some type.
- /// </summary>
- /// <typeparam name="TArgument">The event argument.</typeparam>
- /// <typeparam name="TSender">The event sender.</typeparam>
- public class EventArgs<TSender, TArgument> : EventArgs
- {
- /// <summary>
- /// Construction.
- /// </summary>
- /// <param name="sender">The sender</param>
- /// <param name="argument">The event argument.</param>
- public EventArgs(TSender sender, TArgument argument)
- {
- Sender = sender;
- Argument = argument;
- }
- /// <summary>
- /// The event argument.
- /// </summary>
- public TArgument Argument { get; private set; }
- /// <summary>
- /// The event sender.
- /// </summary>
- public TSender Sender { get; private set; }
- /// <summary>
- /// Presents the class as a string.
- /// </summary>
- /// <returns></returns>
- public override string ToString()
- {
- return string.Format(System.Globalization.CultureInfo.InvariantCulture,
- "EventArgs<{0},{1}>({2}, {3})", Sender.GetType().Name, Argument.GetType().Name, Sender, Argument);
- }
- }
- }
|