private void DoAddSubscription(Type handlerType, string eventName, SubscriptionManagerType subscriptionManagerType) { if (subscriptionManagerType.Equals(SubscriptionManagerType.RpcClient)) { if (!HasSubscriptionsForEventReply(eventName)) { _replyHandlers.Add(eventName, new List <SubscriptionInfo>()); } if (_replyHandlers[eventName].Any(s => s.HandlerType == handlerType)) { throw new ArgumentException( $"ReplyHandler Type {handlerType.Name} already registered for '{eventName}'", nameof(handlerType)); } } else { if (!HasSubscriptionsForEvent(eventName)) { _handlers.Add(eventName, new List <SubscriptionInfo>()); } if (_handlers[eventName].Any(s => s.HandlerType == handlerType)) { throw new ArgumentException( $"Handler Type {handlerType.Name} already registered for '{eventName}'", nameof(handlerType)); } } switch (subscriptionManagerType) { case SubscriptionManagerType.Dynamic: _handlers[eventName].Add(SubscriptionInfo.Dynamic(handlerType)); break; case SubscriptionManagerType.Typed: _handlers[eventName].Add(SubscriptionInfo.Typed(handlerType)); break; case SubscriptionManagerType.Queue: _handlers[eventName].Add(SubscriptionInfo.Queue(handlerType)); break; case SubscriptionManagerType.Rpc: break; case SubscriptionManagerType.RpcClient: _replyHandlers[eventName].Add(SubscriptionInfo.RpcClient(handlerType)); break; case SubscriptionManagerType.RpcServer: break; default: throw new ArgumentOutOfRangeException(nameof(subscriptionManagerType), subscriptionManagerType, null); } }
private SubscriptionInfo(SubscriptionManagerType subscriptionManagerType, Type handlerType) { SubscriptionManagerType = subscriptionManagerType; HandlerType = handlerType; }
private void DoAddSubscriptionReply(Type handlerType, string eventName, SubscriptionManagerType subscriptionManagerType, string eventReplyName) { if (!HasSubscriptionsForEvent(eventName)) { _handlers.Add(eventName, new List <InMemoryEventBusSubscriptionsManager.SubscriptionInfo>()); } if (_handlers[eventName].Any(s => s.HandlerType == handlerType)) { throw new ArgumentException( $"Handler Type {handlerType.Name} already registered for '{eventName}'", nameof(handlerType)); } if (!string.IsNullOrEmpty(eventReplyName)) { if (!HasSubscriptionsForEventReply(eventReplyName)) { _replyHandlers.Add(eventReplyName, new List <InMemoryEventBusSubscriptionsManager.SubscriptionInfo>()); } if (_replyHandlers[eventReplyName].Any(s => s.HandlerType == handlerType)) { throw new ArgumentException( $"ReplyHandler Type {handlerType.Name} already registered for '{eventReplyName}'", nameof(handlerType)); } } switch (subscriptionManagerType) { case SubscriptionManagerType.Dynamic: break; case SubscriptionManagerType.Typed: break; case SubscriptionManagerType.Queue: break; case SubscriptionManagerType.Rpc: _handlers[eventName].Add(InMemoryEventBusSubscriptionsManager.SubscriptionInfo.Rpc(handlerType)); if (!string.IsNullOrEmpty(eventReplyName)) { _replyHandlers[eventReplyName].Add(InMemoryEventBusSubscriptionsManager.SubscriptionInfo.Rpc(handlerType)); } break; case SubscriptionManagerType.RpcClient: break; case SubscriptionManagerType.RpcServer: _handlers[eventName].Add(InMemoryEventBusSubscriptionsManager.SubscriptionInfo.RpcServer(handlerType)); if (!string.IsNullOrEmpty(eventReplyName)) { _replyHandlers[eventReplyName].Add(InMemoryEventBusSubscriptionsManager.SubscriptionInfo.RpcServer(handlerType)); } break; default: throw new ArgumentOutOfRangeException(nameof(subscriptionManagerType), subscriptionManagerType, null); } }