示例#1
0
        /// <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));
        }
示例#2
0
        /// <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();
                }
            }));
        }
示例#3
0
        /// <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();
                }
            });
        }