コード例 #1
0
        public void RegisteryNotification(NotificationDefinition notificationDefinition)
        {
            if (notificationDefinition == null)
            {
                throw new ArgumentNullException(nameof(notificationDefinition));
            }

            if (_notificationsByTopic.ContainsKey(notificationDefinition.Topic))
            {
                throw new ArgumentException($"Notification already registered for topic: {notificationDefinition.Topic}");
            }

            var hasEnum = null != notificationDefinition.EnumValue;

            if (hasEnum && _notificationsByEnum.ContainsKey(notificationDefinition.EnumValue))
            {
                throw new ArgumentException($"Notification already registered for enum: {notificationDefinition.EnumValue}");
            }

            _notificationsByTopic[notificationDefinition.Topic] = notificationDefinition;

            if (hasEnum)
            {
                _notificationsByEnum[notificationDefinition.EnumValue] = notificationDefinition;
            }
        }
コード例 #2
0
 public NotificationSubscription(
     NotificationDefinition notification,
     MethodInfo method,
     string messageParameterName,
     string taskQueue = null) : base(method)
 {
     Notification     = notification ?? throw new ArgumentNullException(nameof(notification));
     MessageParameter = Parameters.FirstOrDefault(x => x.Name == messageParameterName) ?? throw new ArgumentException($"No Parameter {messageParameterName} on {method}");
     TaskQueue        = taskQueue;
 }
コード例 #3
0
     public NotificationSubscription[] GetSubscriptions(NotificationDefinition notificationDefinition)
     {
         if (!NotificationSubscriptions.TryGetValue(notificationDefinition, out var methodHandlers))
         {
             return new NotificationSubscription[] { }
         }
         ;
         return(methodHandlers.ToArray());
     }
 }
コード例 #4
0
        public static NotificationSubscription RegisterSubscription(
            this NotificationOptions options,
            NotificationDefinition notification,
            MethodInfo method,
            string messageParameterName,
            string taskQueue = null)
        {
            var subscription = new NotificationSubscription(notification, method, messageParameterName, taskQueue);

            options.NotificationSubscriptions.Add(subscription);
            return(subscription);
        }