From 29eb28b1f12aff2e82a6f9bcbe74fadc303c8296 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 10 Apr 2018 12:00:42 -0400 Subject: [PATCH 1/4] feat: New delegate for appending items to the ReprBuilder --- ICD.Common.Utils/ReprBuilder.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ICD.Common.Utils/ReprBuilder.cs b/ICD.Common.Utils/ReprBuilder.cs index 6204d52..481feae 100644 --- a/ICD.Common.Utils/ReprBuilder.cs +++ b/ICD.Common.Utils/ReprBuilder.cs @@ -3,6 +3,8 @@ using System.Text; namespace ICD.Common.Utils { + public delegate void AddReprPropertyDelegate(string name, object value); + /// /// Simple class for building a string representation of an object. /// From 8d753e1cf9c70cd12f6db610cfe7ad830c3f35c9 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 10 Apr 2018 12:08:29 -0400 Subject: [PATCH 2/4] feat: Adding IGenericEventArgs interface for convenience --- ICD.Common.Utils/EventArguments/GenericEventArgs.cs | 5 ++++- ICD.Common.Utils/EventArguments/IGenericEventArgs.cs | 10 ++++++++++ ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 ICD.Common.Utils/EventArguments/IGenericEventArgs.cs diff --git a/ICD.Common.Utils/EventArguments/GenericEventArgs.cs b/ICD.Common.Utils/EventArguments/GenericEventArgs.cs index 895a067..9ed83a6 100644 --- a/ICD.Common.Utils/EventArguments/GenericEventArgs.cs +++ b/ICD.Common.Utils/EventArguments/GenericEventArgs.cs @@ -2,8 +2,11 @@ namespace ICD.Common.Utils.EventArguments { - public class GenericEventArgs : EventArgs + public class GenericEventArgs : EventArgs, IGenericEventArgs { + /// + /// Gets the wrapped data associated with the event. + /// public T Data { get; private set; } /// diff --git a/ICD.Common.Utils/EventArguments/IGenericEventArgs.cs b/ICD.Common.Utils/EventArguments/IGenericEventArgs.cs new file mode 100644 index 0000000..626a292 --- /dev/null +++ b/ICD.Common.Utils/EventArguments/IGenericEventArgs.cs @@ -0,0 +1,10 @@ +namespace ICD.Common.Utils.EventArguments +{ + public interface IGenericEventArgs + { + /// + /// Gets the wrapped data associated with the event. + /// + T Data { get; } + } +} diff --git a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj index 63af157..8038e0b 100644 --- a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj +++ b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj @@ -81,6 +81,7 @@ + From b24c93df09836d2a866bb45113f93eb1ef765787 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 10 Apr 2018 14:02:13 -0400 Subject: [PATCH 3/4] docs: Resolving closure warning --- ICD.Common.Utils/Timers/IcdStopwatch.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ICD.Common.Utils/Timers/IcdStopwatch.cs b/ICD.Common.Utils/Timers/IcdStopwatch.cs index 1f9f398..c930671 100644 --- a/ICD.Common.Utils/Timers/IcdStopwatch.cs +++ b/ICD.Common.Utils/Timers/IcdStopwatch.cs @@ -140,6 +140,7 @@ namespace ICD.Common.Utils.Timers { using (IEnumerator enumerator = enumerable.GetEnumerator()) { +// ReSharper disable once AccessToDisposedClosure while (Profile(() => enumerator.MoveNext(), name)) yield return enumerator.Current; } From bd8f7f15a0551aff2a3cd84b7447217cf76cd396 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 10 Apr 2018 17:10:39 -0400 Subject: [PATCH 4/4] refactor: validation --- ICD.Common.Utils/Extensions/EventHandlerExtensions.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ICD.Common.Utils/Extensions/EventHandlerExtensions.cs b/ICD.Common.Utils/Extensions/EventHandlerExtensions.cs index 958cf38..cb812b7 100644 --- a/ICD.Common.Utils/Extensions/EventHandlerExtensions.cs +++ b/ICD.Common.Utils/Extensions/EventHandlerExtensions.cs @@ -14,6 +14,9 @@ namespace ICD.Common.Utils.Extensions /// 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(this EventHandler 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); }