This commit is contained in:
Jack Kanarish
2018-04-11 11:20:58 -04:00
6 changed files with 27 additions and 1 deletions

View File

@@ -2,8 +2,11 @@
namespace ICD.Common.Utils.EventArguments
{
public class GenericEventArgs<T> : EventArgs
public class GenericEventArgs<T> : EventArgs, IGenericEventArgs<T>
{
/// <summary>
/// Gets the wrapped data associated with the event.
/// </summary>
public T Data { get; private set; }
/// <summary>

View File

@@ -0,0 +1,10 @@
namespace ICD.Common.Utils.EventArguments
{
public interface IGenericEventArgs<T>
{
/// <summary>
/// Gets the wrapped data associated with the event.
/// </summary>
T Data { get; }
}
}

View File

@@ -14,6 +14,9 @@ namespace ICD.Common.Utils.Extensions
/// <param name="sender"></param>
public static void Raise(this EventHandler extends, object sender)
{
if (sender == null)
throw new ArgumentNullException("sender");
if (extends != null)
extends(sender, EventArgs.Empty);
}
@@ -28,6 +31,12 @@ namespace ICD.Common.Utils.Extensions
public static void Raise<T>(this EventHandler<T> extends, object sender, T args)
where T : EventArgs
{
if (sender == null)
throw new ArgumentNullException("sender");
if (args == null)
throw new ArgumentNullException("args");
if (extends != null)
extends(sender, args);
}

View File

@@ -81,6 +81,7 @@
<Compile Include="EventArguments\DateTimeEventArgs.cs" />
<Compile Include="EventArguments\FloatEventArgs.cs" />
<Compile Include="EventArguments\GenericEventArgs.cs" />
<Compile Include="EventArguments\IGenericEventArgs.cs" />
<Compile Include="EventArguments\IntEventArgs.cs" />
<Compile Include="EventArguments\StringEventArgs.cs" />
<Compile Include="EventArguments\UShortEventArgs.cs" />

View File

@@ -3,6 +3,8 @@ using System.Text;
namespace ICD.Common.Utils
{
public delegate void AddReprPropertyDelegate(string name, object value);
/// <summary>
/// Simple class for building a string representation of an object.
/// </summary>

View File

@@ -140,6 +140,7 @@ namespace ICD.Common.Utils.Timers
{
using (IEnumerator<T> enumerator = enumerable.GetEnumerator())
{
// ReSharper disable once AccessToDisposedClosure
while (Profile(() => enumerator.MoveNext(), name))
yield return enumerator.Current;
}