diff --git a/ICD.Common.Utils/Extensions/ReflectionExtensions.cs b/ICD.Common.Utils/Extensions/ReflectionExtensions.cs index 4e30516..e19698c 100644 --- a/ICD.Common.Utils/Extensions/ReflectionExtensions.cs +++ b/ICD.Common.Utils/Extensions/ReflectionExtensions.cs @@ -128,5 +128,22 @@ namespace ICD.Common.Utils.Extensions .Distinct(); } #endif + + /// + /// Gets the EventArgs Type for the given event. + /// + /// + /// + public static Type GetEventArgsType([NotNull] this EventInfo extends) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + Type eventHandlerType = extends.EventHandlerType; + return eventHandlerType == typeof(EventHandler) + ? typeof(EventArgs) + : eventHandlerType.GetInnerGenericTypes(typeof(EventHandler<>)) + .First(); + } } }