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; } }
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; }
public NotificationSubscription[] GetSubscriptions(NotificationDefinition notificationDefinition) { if (!NotificationSubscriptions.TryGetValue(notificationDefinition, out var methodHandlers)) { return new NotificationSubscription[] { } } ; return(methodHandlers.ToArray()); } }
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); }