From 7ab06fdb94119ece4e40a8467404d789f5a3d102 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Mon, 9 Apr 2018 15:24:22 -0400 Subject: [PATCH] feat: shim for platform independent delegate creation --- ICD.Common.Utils/ReflectionUtils.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ICD.Common.Utils/ReflectionUtils.cs b/ICD.Common.Utils/ReflectionUtils.cs index 94a9542..8e661b9 100644 --- a/ICD.Common.Utils/ReflectionUtils.cs +++ b/ICD.Common.Utils/ReflectionUtils.cs @@ -387,5 +387,23 @@ namespace ICD.Common.Utils return Convert.ChangeType(value, type, null); } + + /// + /// Platform independant delegate instantiation. + /// + /// + /// + /// + /// + public static Delegate CreateDelegate(Type type, object firstArgument, MethodInfo method) + { + return +#if SIMPLSHARP + CDelegate +#else + Delegate +#endif + .CreateDelegate(type, firstArgument, method); + } } }