feat: Cross-platform extension method for getting MethodInfo from a delegate

This commit is contained in:
Chris Cameron
2018-07-19 11:35:23 -04:00
parent 2166596726
commit 6fb290a0ab

View File

@@ -1,4 +1,9 @@
using System;
#if SIMPLSHARP
using Crestron.SimplSharp.Reflection;
#else
using System.Reflection;
#endif
namespace ICD.Common.Utils.Extensions
{
@@ -34,5 +39,22 @@ namespace ICD.Common.Utils.Extensions
if (extends != null)
extends(sender, args);
}
/// <summary>
/// Cross-platform shim for getting MethodInfo for the delegate.
/// </summary>
/// <param name="extends"></param>
/// <returns></returns>
public static MethodInfo GetMethodInfo(this Delegate extends)
{
if (extends == null)
throw new ArgumentNullException("extends");
#if SIMPLSHARP
return extends.GetMethod();
#else
return extends.Method;
#endif
}
}
}