/// <summary> /// Adds a binding. /// </summary> /// <param name="binding">The binding to add.</param> /// <returns>A disposable used to remove the binding.</returns> public IDisposable Add(IObservable <object> binding) { Contract.Requires <ArgumentNullException>(binding != null); var entry = new PriorityBindingEntry(this, _nextIndex++); var node = Bindings.AddFirst(entry); entry.Start(binding); return(new RemoveBindingDisposable(node, Bindings, this)); }
/// <summary> /// Adds a binding. /// </summary> /// <param name="binding">The binding to add.</param> /// <returns>A disposable used to remove the binding.</returns> public IDisposable Add(IObservable <object> binding) { Contract.Requires <ArgumentNullException>(binding != null); var entry = new PriorityBindingEntry(this, _nextIndex++); var node = Bindings.AddFirst(entry); entry.Start(binding); return(Disposable.Create(() => { Bindings.Remove(node); entry.Dispose(); if (entry.Index >= ActiveBindingIndex) { ActivateFirstBinding(); } })); }
/// <summary> /// Adds a binding. /// </summary> /// <param name="binding">The binding to add.</param> /// <returns>A disposable used to remove the binding.</returns> public IDisposable Add(IObservable<object> binding) { Contract.Requires<ArgumentNullException>(binding != null); var entry = new PriorityBindingEntry(this, _nextIndex++); var node = Bindings.AddFirst(entry); entry.Start(binding); return Disposable.Create(() => { Bindings.Remove(node); entry.Dispose(); if (entry.Index >= ActiveBindingIndex) { ActivateFirstBinding(); } }); }