mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
feat: Cross-platform extension method for getting MethodInfo from a delegate
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
#if SIMPLSHARP
|
||||||
|
using Crestron.SimplSharp.Reflection;
|
||||||
|
#else
|
||||||
|
using System.Reflection;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ICD.Common.Utils.Extensions
|
namespace ICD.Common.Utils.Extensions
|
||||||
{
|
{
|
||||||
@@ -34,5 +39,22 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
if (extends != null)
|
if (extends != null)
|
||||||
extends(sender, args);
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user