void IObserverCollection.Detach(IObserve observer, Type @event)
 {
     var observers = Observers(@event);
     
     if (observers != null)
         observers.Remove(observer);
 }
        public async Task Unsubscribe(string source, IObserve proxy, params Type[] notifications)
        {
            Type notifier = null;

            foreach (var notification in notifications)
            {
                Type grainType;
                if (!notifiers.TryGetValue(notification, out grainType))
                {
                    throw new ApplicationException("Can't find source grain which handles notification type " + notification.FullName);
                }

                if (notifier != null && notifier != grainType)
                {
                    throw new ApplicationException("Can't unsubscribe from multiple grain types for the same source id");
                }

                notifier = grainType;
            }

            var reference  = factory.GetReference(notifier, source);
            var observable = (IMessageBasedGrain)reference;

            await observable.Detach(proxy, notifications);
        }
Example #3
0
 public void RemoveObserver(IObserve ob)
 {
     if (observers.Contains(ob))
     {
         observers.Remove(ob);
     }
 }
        void IObserverCollection.Detach(IObserve observer, Type notification)
        {
            var observers = Observers(notification);

            if (observers != null)
            {
                observers.Remove(observer);
            }
        }
        void IObserverCollection.Attach(IObserve observer, Type notification)
        {
            if (RecordedSubscriptions.Any(x => x.Observer == observer && x.Notification == notification))
            {
                return;
            }

            RecordedSubscriptions.Add(new RecordedSubscription(observer, notification));
        }
        public void SetUp()
        {
            bus = MessageBus.Instance;

            client = new Observe();
            proxy  = SubscriptionManager.Instance.CreateProxy(client).Result;

            collection = new ObserverCollection();
        }
Example #7
0
        /// <summary>
        /// Attaches given selective observer for the given types of notifications.
        /// </summary>
        /// <param name="observer">The observer proxy.</param>
        /// <param name="notifications">The types of notifications</param>
        /// <remarks>The operation is idempotent</remarks>
        protected virtual Task OnAttach(IObserve observer, params Type[] notifications)
        {
            foreach (var notification in notifications)
            {
                observers.Attach(observer, notification);
            }

            return(TaskDone.Done);
        }
 static void TryDeliver(IObserve observer, Notification[] notifications, string source, ICollection <IObserve> failed)
 {
     try
     {
         observer.On(source, notifications);
     }
     catch (Exception)
     {
         failed.Add(observer);
     }
 }
        void IObserverCollection.Attach(IObserve observer, Type notification)
        {
            var observers = Observers(notification);

            if (observers == null)
            {
                observers = new HashSet <IObserve>();
                subscriptions.Add(notification, observers);
            }

            observers.Add(observer);
        }
Example #10
0
        void IObserverCollection.Attach(IObserve observer, Type @event)
        {
            var observers = Observers(@event);

            if (observers == null)
            {
                observers = new HashSet<IObserve>();
                subscriptions.Add(@event, observers);
            }

            observers.Add(observer);
        }
Example #11
0
 public void Detach(IObserve observe)
 {
     ls.Remove(observe);
 }
Example #12
0
 public void registerSubscriber(IObserve observe)
 {
     list.Add(observe);
 }
 public void Add(IObserve observer)
 {
     _observerlist.Add(observer);
 }
Example #14
0
 public void Attach(IObserve observe)
 {
     ls.Add(observe);
 }
Example #15
0
 public void AddObserve(IObserve observe)
 {
     observes.Add(observe);
 }
 public void SetUp()
 {
     client     = new Observe();
     proxy      = SubscriptionManager.Instance.CreateProxy(client).Result;
     collection = new ObserverCollection();
 }
Example #17
0
 //对同一个订阅号,新增和删除订阅者的操作
 public void AddObserver(IObserve ob)
 {
     observers.Add(ob);
 }
Example #18
0
 public Task SubscribeForUpdates(IObserve subscriber)
 {
     subscribers.Subscribe(subscriber);
     return(TaskDone.Done);
 }
Example #19
0
 // accept subscriptions 
 public Task SubscribeForUpdates(IObserve subscriber)
 {
     // add new subscriber to list of subscribers
     subscribers.Subscribe(subscriber);
     return TaskDone.Done;
 }
Example #20
0
 public void RemoveObserve(IObserve observe)
 {
     observes.Remove(observe);
 }
Example #21
0
 public static void DeleteObjectReference(IObserve reference)
 {
     GrainReference.DeleteObjectReference(reference);
 }
Example #22
0
 public async static System.Threading.Tasks.Task<IObserve> CreateObjectReference(IObserve obj)
 {
     if (methodInvoker == null) methodInvoker = new ObserveMethodInvoker();
     return ObserveFactory.Cast(await GrainReference.CreateObjectReference(obj, methodInvoker));
 }
Example #23
0
 private Message PerformMapping(IObserve source)
 {
     return Mapping.Map<IObserve, Observe>(source);
 }
Example #24
0
 void Initialize(IObserve proxy)
 {
     this.proxy = proxy;
 }
Example #25
0
 // implemented ISubject methods
 public void RegisterObserver(IObserve o)
 {
     observers.Add(o);
 }
 public RecordedSubscription(IObserve observer, Type notification)
 {
     Observer     = observer;
     Notification = notification;
 }
Example #27
0
 public async static System.Threading.Tasks.Task <IObserve> CreateObjectReference(IObserve obj)
 {
     if (methodInvoker == null)
     {
         methodInvoker = new ObserveMethodInvoker();
     }
     return(ObserveFactory.Cast(await GrainReference.CreateObjectReference(obj, methodInvoker)));
 }
Example #28
0
 private Message PerformMapping(IObserve source)
 {
     return(Mapping.Map <IObserve, Observe>(source));
 }
 void IObserverCollection.Detach(IObserve observer, Type notification)
 {
     RecordedSubscriptions.RemoveAll(x => x.Observer == observer && x.Notification == notification);
 }
Example #30
0
 Task IMessageBasedGrain.Detach(IObserve observer, params Type[] notifications)
 {
     return(OnDetach(observer, notifications));
 }
 public void Remove(IObserve observer)
 {
     this._observerlist.Remove(observer);
 }
Example #32
0
 public void removeSubscriber(IObserve observe)
 {
     list.Remove(observe);
 }
Example #33
0
 // accept subscriptions
 public Task SubscribeForUpdates(IObserve subscriber)
 {
     // add new subscriber to list of subscribers
     subscribers.Subscribe(subscriber);
     return(TaskDone.Done);
 }
Example #34
0
 public void RemoveObserver(IObserve o)
 {
     observers.Remove(o);
 }
 public async Task <IObserve> CreateProxy(IObserve client)
 {
     return(await ObserveFactory.CreateObjectReference(client));
 }
Example #36
0
 public static void DeleteObjectReference(IObserve reference)
 {
     GrainReference.DeleteObjectReference(reference);
 }
 public void DeleteProxy(IObserve observer)
 {
     ObserveFactory.DeleteObjectReference(observer);
 }