private static bool TheMessageDoNotSatisfyMyFilter(IListenTo listener, IEvent message, Type messageType) { var closedInterface = typeof(IListenTo<>.ThatSatisfy).MakeGenericType(messageType); var genericMethod = SatisfiedByMethod(closedInterface); if (genericMethod == null) return true; return !(bool)genericMethod.Invoke(listener, new[] { message }); }
private static bool TheMessageWasNotSentToMe(IListenTo listener, dynamic message) { var messageIsDirectedEvent = ((Type)message.GetType()).ImplementsInterfaceTemplate(typeof(IDirectedEvent<>)); if (!messageIsDirectedEvent) return true; if (message.CurrentReceiver == null) return true; var messageWasSentToMe = message.CurrentReceiver.Equals(listener); return !messageWasSentToMe; }
public void Unsubscribe <TEvent>(IListenTo <TEvent> listener) where TEvent : Event { Unsubscribe(typeof(TEvent), listener); }