示例#1
0
 /// <summary>
 /// Check if a given <see cref="Action"/> is subscribed to the <see cref="PubSubEvent"/>
 /// </summary>
 /// <param name="subscriber">The <see cref="Action"/> to match against the subscriptions</param>
 /// <returns>Returns <see langword="true"/> if the subscription exists, otherwise returns <see langword="false"/></returns>
 public virtual bool Contains(Action subscriber)
 {
     lock (Subscriptions)
     {
         var subscription = Subscriptions.Cast <EventSubscription>().FirstOrDefault(evt => evt.GetAction == subscriber);
         return(subscription != null);
     }
 }
示例#2
0
 /// <summary>
 /// Returns <see langword="true"/> if there is a subscriber matching <see cref="Action"/>.
 /// </summary>
 /// <param name="subscriber">The <see cref="Action"/> used when subscribing to the event.</param>
 /// <returns><see langword="true"/> if there is an <see cref="Action"/> that matches; otherwise <see langword="false"/>.</returns>
 public virtual bool Contains(Action subscriber)
 {
     IEventSubscription eventSubscription;
     lock (Subscriptions)
     {
         eventSubscription = Subscriptions.Cast<EventSubscription>().FirstOrDefault(evt => evt.Action == subscriber);
     }
     return eventSubscription != null;
 }
示例#3
0
 /// <summary>
 /// Removes the first subscriber matching <see cref="Action"/> from the subscribers' list.
 /// </summary>
 /// <param name="subscriber">The <see cref="Action"/> used when subscribing to the event.</param>
 public virtual void Unsubscribe(Action subscriber)
 {
     lock (Subscriptions) {
         IEventSubscription eventSubscription = Subscriptions.Cast <EventSubscription> ().FirstOrDefault(evt => evt.Action == subscriber);
         if (eventSubscription != null)
         {
             Subscriptions.Remove(eventSubscription);
         }
     }
 }
        public virtual bool Contains(Action <MessageSender, TMessage> subscriber)
        {
            IMsgSubscription msgSubscription;

            lock (Subscriptions)
            {
                msgSubscription = Subscriptions.Cast <MsgSubscription <TMessage> >().FirstOrDefault(evt => evt.Action == subscriber);
            }
            return(msgSubscription != null);
        }
示例#5
0
        /// <summary>
        /// Verifica se existe alguma inscrição igual a instancia informada..
        /// </summary>
        /// <param name="subscriber"></param>
        /// <returns></returns>
        public virtual bool Contains(Action <TPayload> subscriber)
        {
            IDomainEventSubscription eventSubscription;

            lock (Subscriptions)
            {
                eventSubscription = Subscriptions.Cast <DomainEventSubscription <TPayload> >().FirstOrDefault(evt => evt.Action == subscriber);
            }
            return(eventSubscription != null);
        }
 /// <summary>
 /// 取消匹配的第一个订阅
 /// </summary>
 /// <param name="subscriber"></param>
 public virtual void Unsubscribe(Action <MessageSender, TMessage> subscriber)
 {
     lock (Subscriptions)
     {
         IMsgSubscription eventSubscription = Subscriptions.Cast <MsgSubscription <TMessage> >().FirstOrDefault(evt => evt.Action == subscriber);
         if (eventSubscription != null)
         {
             Subscriptions.Remove(eventSubscription);
         }
     }
 }