コード例 #1
0
        private void RemoveHandlerPrivate <TMessage>(ISubscriberTo <TMessage> subscriberTo) where TMessage : class
        {
            if (ContainsKey(typeof(TMessage)))
            {
                this[typeof(TMessage)].RemoveAll(wr => wr.Target.As <ISubscriberTo <TMessage> >() == subscriberTo);
            }

            InvalidateHandlers();
        }
コード例 #2
0
        public void RemoveHandler <TMessage>(ISubscriberTo <TMessage> subscriberTo) where TMessage : class
        {
            ArgumentMust.NotBeNull(() => subscriberTo);

            lock (_thisLock)
            {
                RemoveHandlerPrivate(subscriberTo);
            }
        }
コード例 #3
0
        private void AddHandlerPrivate <TMessage>(ISubscriberTo <TMessage> subscriberTo) where TMessage : class
        {
            if (ContainsKey(typeof(TMessage)))
            {
                if (this[typeof(TMessage)].All(wr => wr.Target.As <ISubscriberTo <TMessage> >() != subscriberTo))
                {
                    this[typeof(TMessage)].Add(new WeakReference(subscriberTo));
                }
            }
            else
            {
                Add(typeof(TMessage), new Handlers(new WeakReference(subscriberTo)));
            }

            InvalidateHandlers();
        }
コード例 #4
0
        public void UnsubscribeFrom <TMessage>(ISubscriberTo <TMessage> subscriberTo) where TMessage : class
        {
            ArgumentMust.NotBeNull(() => subscriberTo);

            _handlers.RemoveHandler(subscriberTo);
        }
コード例 #5
0
        public void SubscribeTo <TMessage>(ISubscriberTo <TMessage> subscriberTo) where TMessage : class
        {
            ArgumentMust.NotBeNull(() => subscriberTo);

            _handlers.AddHandler(subscriberTo);
        }