コード例 #1
0
        public void Unsubscribe <T, TH>() where T : DefaultEvent where TH : IEventHandler <T>
        {
            var eventName = subscriptionManager.GetEventKey <T>();

            Console.WriteLine("Unsubscribing from event {EventName}", eventName);
            Console.WriteLine();
            subscriptionManager.RemoveSubscription <T, TH>();
        }
コード例 #2
0
        public void Unsubscribe <T, TH>() where T : IntegrationEvent where TH : IIntegrationEventHandler <T>
        {
            var eventName = _subscriptionsManager.GetEventKey <T>();

            _logger.LogInformation("Unsubscribing from event {EventName}", eventName);

            _subscriptionsManager.RemoveSubscription <T, TH>();
        }
コード例 #3
0
        public void RemoveSubscribe <TEvent, TEventHandler>()
            where TEvent : Event
            where TEventHandler : IEventHandler <TEvent>
        {
            var eventName = _subscriptionsManager.GetEventKey <TEvent>();

            _logger.LogInformation("Unsubscribing from event {EventName}", eventName);

            _subscriptionsManager.RemoveSubscription <TEvent, TEventHandler>();
        }
コード例 #4
0
        /// <summary>
        /// Unsubscribe form the event type T
        /// </summary>
        /// <param name="guid">Subscription guid</param>
        /// <typeparam name="T">Event type</typeparam>
        /// <typeparam name="TH"></typeparam>
        /// <returns>Result</returns>
        public bool Unsubscribe <T, TH>(string guid)
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler <T>
        {
            if (!_subscriptionsManager.HasEventTopic <T>() || !_subscriptionsManager.HasSubscription <T>(guid))
            {
                return(false);
            }

            var model = _integrationEventsRespository.SetModelAsync <T, TH>(false);

            if (model == null)
            {
                throw new Exception($"Error on usubscription to the integration event {typeof(T).Name}");
            }

            _subscriptionsManager.RemoveSubscription <T>(guid);

            return(!_subscriptionsManager.HasSubscription <T>(guid));
        }
コード例 #5
0
        public async Task <MqttClientUnsubscribeResult> UnsubscribeAsync(SubscriptionInfo subscriptionInfo, CancellationToken cancellationToken = default)
        {
            var connection = _mqttPersisterConnection;

            if (!connection.IsConnected)
            {
                await connection.TryConnectAsync(cancellationToken : cancellationToken);
            }

            var topic = subscriptionInfo?.Topic;

            _logger.LogInformation($"Unsubscribing to topic {topic} with {subscriptionInfo?.ConsumerType?.Name}");

            var containsKey = _subsManager.HasSubscriptionsForEvent(topic);

            if (!containsKey)
            {
                _subsManager.RemoveSubscription(subscriptionInfo);
                return(await connection.RemoveSubscriptionAsync(topic));
            }

            return(null);
        }
コード例 #6
0
 public void UnSubscribe <T, TH>()
     where T : EventArguments
     where TH : IEventHandler <T>
 {
     _subsManager.RemoveSubscription <T, TH>();
 }
コード例 #7
0
 public void Unsubscribe <TIntegrationEvent, TIntegrationEventHandler>()
     where TIntegrationEvent : IntegrationEvent
     where TIntegrationEventHandler : IIntegrationEventHandler <TIntegrationEvent>
 {
     _subscriptionsManager.RemoveSubscription <TIntegrationEvent, TIntegrationEventHandler>();
 }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TEvent"></typeparam>
 /// <typeparam name="TEventHandler"></typeparam>
 public void RemoveEventHandler <TEvent, TEventHandler>()
     where TEventHandler : IEventHandler <TEvent>
 {
     subscriptionsManager.RemoveSubscription <TEvent, TEventHandler>();
 }