Exemplo n.º 1
0
            public void Dispose()
            {
                LinkedListNode <PriorityBindingEntry> binding = Interlocked.Exchange(ref _binding, null);

                if (binding == null)
                {
                    // Some system is trying to remove binding twice.
                    Debug.Assert(false);

                    return;
                }

                PriorityBindingEntry entry = binding.Value;

                if (!entry.HasCompleted)
                {
                    _bindings.Remove(binding);

                    entry.Dispose();

                    if (entry.Index >= _priorityLevel.ActiveBindingIndex)
                    {
                        _priorityLevel.ActivateFirstBinding();
                    }
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Invoked when an entry in <see cref="Bindings"/> completes.
        /// </summary>
        /// <param name="entry">The entry that completed.</param>
        public void Completed(PriorityBindingEntry entry)
        {
            Bindings.Remove(entry);

            if (entry.Index >= ActiveBindingIndex)
            {
                ActivateFirstBinding();
            }
        }
Exemplo n.º 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(new RemoveBindingDisposable(node, Bindings, this));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Invoked when an entry in <see cref="Bindings"/> changes value.
 /// </summary>
 /// <param name="entry">The entry that changed.</param>
 public void Changed(PriorityBindingEntry entry)
 {
     if (entry.Index >= ActiveBindingIndex)
     {
         if (entry.Value != AvaloniaProperty.UnsetValue)
         {
             Value = entry.Value;
             ActiveBindingIndex = entry.Index;
             Owner.LevelValueChanged(this);
         }
         else
         {
             ActivateFirstBinding();
         }
     }
 }
Exemplo n.º 5
0
            public void Dispose()
            {
                PriorityBindingEntry entry = _binding.Value;

                if (!entry.HasCompleted)
                {
                    _bindings.Remove(_binding);

                    entry.Dispose();

                    if (entry.Index >= _priorityLevel.ActiveBindingIndex)
                    {
                        _priorityLevel.ActivateFirstBinding();
                    }
                }
            }
Exemplo n.º 6
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();
                }
            }));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Invoked when an entry in <see cref="Bindings"/> encounters a recoverable error.
 /// </summary>
 /// <param name="entry">The entry that completed.</param>
 /// <param name="error">The error.</param>
 public void Error(PriorityBindingEntry entry, BindingNotification error)
 {
     Owner.LevelError(this, error);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Invoked when an entry in <see cref="Bindings"/> reports validation status.
 /// </summary>
 /// <param name="entry">The entry that completed.</param>
 /// <param name="validationStatus">The validation status.</param>
 public void Validation(PriorityBindingEntry entry, IValidationStatus validationStatus)
 {
     _owner.LevelValidation(this, validationStatus);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Invoked when an entry in <see cref="Bindings"/> encounters a recoverable error.
 /// </summary>
 /// <param name="entry">The entry that completed.</param>
 /// <param name="error">The error.</param>
 public void Error(PriorityBindingEntry entry, BindingError error)
 {
     _owner.LevelError(this, error);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Invoked when an entry in <see cref="Bindings"/> completes.
        /// </summary>
        /// <param name="entry">The entry that completed.</param>
        public void Completed(PriorityBindingEntry entry)
        {
            Bindings.Remove(entry);

            if (entry.Index >= ActiveBindingIndex)
            {
                ActivateFirstBinding();
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Invoked when an entry in <see cref="Bindings"/> changes value.
 /// </summary>
 /// <param name="entry">The entry that changed.</param>
 public void Changed(PriorityBindingEntry entry)
 {
     if (entry.Index >= ActiveBindingIndex)
     {
         if (entry.Value != AvaloniaProperty.UnsetValue)
         {
             Value = entry.Value;
             ActiveBindingIndex = entry.Index;
             _owner.LevelValueChanged(this);
         }
         else
         {
             ActivateFirstBinding();
         }
     }
 }
Exemplo n.º 12
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();
                }
            });
        }
Exemplo n.º 13
0
 /// <summary>
 /// Invoked when an entry in <see cref="Bindings"/> reports validation status.
 /// </summary>
 /// <param name="entry">The entry that completed.</param>
 /// <param name="validationStatus">The validation status.</param>
 public void Validation(PriorityBindingEntry entry, IValidationStatus validationStatus)
 {
     _owner.LevelValidation(this, validationStatus);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Invoked when an entry in <see cref="Bindings"/> encounters a recoverable error.
 /// </summary>
 /// <param name="entry">The entry that completed.</param>
 /// <param name="error">The error.</param>
 public void Error(PriorityBindingEntry entry, BindingError error)
 {
     _owner.LevelError(this, error);
 }