void InvokeCompatibleCallbacks(FakeBusEvent fakeBusEvent) { foreach (var callback in _callbacks) { var compatibleHandlerType = typeof(Action <>).MakeGenericType(fakeBusEvent.GetType()); if (!compatibleHandlerType.IsInstanceOfType(callback)) { continue; } try { callback.DynamicInvoke(fakeBusEvent); } catch (Exception exception) { throw new TargetInvocationException($"Error invoking callback for fake bus event {fakeBusEvent}", exception); } } }
public void Record(FakeBusEvent fakeBusEvent) { AddFakeBusEvent(fakeBusEvent); InvokeCompatibleCallbacks(fakeBusEvent); }
void AddFakeBusEvent(FakeBusEvent fakeBusEvent) { _events.Enqueue(fakeBusEvent); }
void Record(FakeBusEvent fakeBusEvent) { _recorder.Record(fakeBusEvent); }