public void Run(ExecutionContextLightup executionContext, Action<object> callback, object state) { if (LightupType.ExecutionContext == null || LightupType.ContextCallback == null) throw new PlatformNotSupportedException(); // Replace the Action<object> with a ContextCallback Delegate contextCallback = LightupServices.ReplaceWith(callback, LightupType.ContextCallback); Type actionRepresentingSignature = typeof(Action<,,>).MakeGenericType(LightupType.ExecutionContext, LightupType.ContextCallback, typeof(object)); Delegate d = GetMethodAccessor(ref _run, actionRepresentingSignature, "Run"); d.DynamicInvoke(executionContext._executionContext, contextCallback, state); }
public void Run(ExecutionContextLightup executionContext, Action <object> callback, object state) { if (LightupType.ExecutionContext == null || LightupType.ContextCallback == null) { throw new PlatformNotSupportedException(); } Delegate dlg = LightupServices.ReplaceWith(callback, LightupType.ContextCallback); Type type = typeof(Action <, ,>).MakeGenericType(new Type[] { LightupType.ExecutionContext, LightupType.ContextCallback, typeof(object) }); Delegate methodAccessor = base.GetMethodAccessor(ref _run, type, "Run", true); methodAccessor.DynamicInvoke(new object[] { executionContext._executionContext, dlg, state }); }