public void AddProxy(ObserverProxy proxy) { if (this.proxies.ContainsKey(proxy.ID)) { Log <Observable> .Logger.Error("Duplicated proxy"); return; } this.proxies.Add(proxy.ID, proxy); this.Collection.Proxies.Add(proxy.ID, proxy); }
public void RemoveProxy(ObserverProxy proxy) { ObserverProxy observerProxy; if (!this.proxies.TryGetValue(proxy.ID, out observerProxy) || proxy != observerProxy) { Log <Observable> .Logger.Warn("Try remove not linked proxy"); return; } this.proxies.Remove(proxy.ID); this.Collection.Proxies.Remove(proxy.ID); }
private void AddObserverHandler(EntityConnection conn, object msg) { AddObserver addObserver = msg as AddObserver; Observable observable; if (!this.observables.TryGetValue(addObserver.ID, out observable)) { Log <ObservableCollection> .Logger.WarnFormat("No observable : [{0}]", addObserver.ID); conn.SendMessage(new AddFail(addObserver.ID)); return; } ObserverProxy newProxy = new ObserverProxy(this.ProxyIDIssuance.ReserveNext(), observable, conn); observable.AddProxy(newProxy); conn.Closed += delegate(object sender, EventArgs <IEntityProxy> e) { newProxy.Close(); }; conn.SendMessage(new AddOk(observable.ID, newProxy.ID)); }