public static void IfInvoke <TKey>(this IMessageObject <TKey> message, Type exptecedMessageType, Action action) { Type msgType = message.GetType(); ThrowOnNotAssignable(typeof(IMessageObject <TKey>), exptecedMessageType); if (msgType == exptecedMessageType) { action(); } }
public Task ReceiveCommandAsync(IMessageObject <TKey> message) => asyncMessages[message.GetType()].InvokeAsync(message);
public virtual void ReceiveCommand(IMessageObject <TKey> message) => messages[message.GetType()].Invoke(message);