mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-13 20:47:24 +00:00
feat: Cross-platform extension method for getting MethodInfo from a delegate
This commit is contained in:
parent
2166596726
commit
6fb290a0ab
1 changed files with 22 additions and 0 deletions
|
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue