public Action <object, object[]> GetVoidMethodInvoker( MethodInfo methodInfo) { Action <object, object[]> action; var lockSlim = voidMethodLockSlim; var dictionary = voidMethodDictionary; lockSlim.EnterUpgradeableReadLock(); try { if (!dictionary.TryGetValue(methodInfo, out action)) { lockSlim.EnterWriteLock(); try { if (!dictionary.TryGetValue(methodInfo, out action)) { action = ReflectionCompiler.CreateMethodAction(methodInfo); dictionary[methodInfo] = action; } } finally { lockSlim.ExitWriteLock(); } } } finally { lockSlim.ExitUpgradeableReadLock(); } return(action); }
public Action <object, object[]> GetVoidMethodInvoker( MethodInfo methodInfo, DelegateCreationMode creationMode) { var dictionary = voidMethodDictionary; if (!dictionary.TryGetValue(methodInfo, out var result)) { switch (creationMode) { case DelegateCreationMode.SlowCreationFastPerformance: result = ReflectionCompiler.CreateMethodAction(methodInfo); break; default: result = (owner, args) => methodInfo.Invoke(owner, args); break; } dictionary[methodInfo] = result; } return(result); }