diff --git a/src/Avalonia.Base/AvaloniaObject.cs b/src/Avalonia.Base/AvaloniaObject.cs
index 761c0618daa..4580ef6c58f 100644
--- a/src/Avalonia.Base/AvaloniaObject.cs
+++ b/src/Avalonia.Base/AvaloniaObject.cs
@@ -22,7 +22,7 @@ namespace Avalonia
///
/// This class is analogous to DependencyObject in WPF.
///
- public class AvaloniaObject : IAvaloniaObject, IAvaloniaObjectDebug, INotifyPropertyChanged, IPriorityValueOwner
+ public class AvaloniaObject : IAvaloniaObject, IAvaloniaObjectDebug, INotifyPropertyChanged
{
///
/// The parent object that inherited values are inherited from.
@@ -45,21 +45,8 @@ public class AvaloniaObject : IAvaloniaObject, IAvaloniaObjectDebug, INotifyProp
///
private EventHandler _propertyChanged;
- private DeferredSetter _directDeferredSetter;
private ValueStore _values;
-
- ///
- /// Delayed setter helper for direct properties. Used to fix #855.
- ///
- private DeferredSetter DirectPropertyDeferredSetter
- {
- get
- {
- return _directDeferredSetter ??
- (_directDeferredSetter = new DeferredSetter());
- }
- }
-
+ private ValueStore Values => _values ?? (_values = new ValueStore(this));
///
/// Initializes a new instance of the class.
@@ -225,7 +212,7 @@ public object GetValue(AvaloniaProperty property)
}
else if (_values != null)
{
- var result = _values.GetValue(property);
+ var result = Values.GetValue(property);
if (result == AvaloniaProperty.UnsetValue)
{
@@ -376,12 +363,7 @@ public IDisposable Bind(
description,
priority);
- if (_values == null)
- {
- _values = new ValueStore(this);
- }
-
- return _values.AddBinding(property, source, priority);
+ return Values.AddBinding(property, source, priority);
}
}
@@ -414,9 +396,8 @@ public void Revalidate(AvaloniaProperty property)
VerifyAccess();
_values?.Revalidate(property);
}
-
- ///
- void IPriorityValueOwner.Changed(AvaloniaProperty property, int priority, object oldValue, object newValue)
+
+ internal void PriorityValueChanged(AvaloniaProperty property, int priority, object oldValue, object newValue)
{
oldValue = (oldValue == AvaloniaProperty.UnsetValue) ?
GetDefaultValue(property) :
@@ -439,9 +420,8 @@ void IPriorityValueOwner.Changed(AvaloniaProperty property, int priority, object
(BindingPriority)priority);
}
}
-
- ///
- void IPriorityValueOwner.BindingNotificationReceived(AvaloniaProperty property, BindingNotification notification)
+
+ internal void BindingNotificationReceived(AvaloniaProperty property, BindingNotification notification)
{
UpdateDataValidation(property, notification);
}
@@ -456,7 +436,7 @@ Delegate[] IAvaloniaObjectDebug.GetPropertyChangedSubscribers()
/// Gets all priority values set on the object.
///
/// A collection of property/value tuples.
- internal IDictionary GetSetValues() => _values?.GetSetValues();
+ internal IDictionary GetSetValues() => Values?.GetSetValues();
///
/// Forces revalidation of properties when a property value changes.
@@ -566,12 +546,12 @@ protected bool SetAndRaise(
T value)
{
Contract.Requires(setterCallback != null);
- return DirectPropertyDeferredSetter.SetAndNotify(
+ return Values.Setter.SetAndNotify(
property,
ref field,
- (object val, ref T backing, Action notify) =>
+ (object update, ref T backing, Action notify) =>
{
- setterCallback((T)val, ref backing, notify);
+ setterCallback((T)update, ref backing, notify);
return true;
},
value);
@@ -737,13 +717,8 @@ private void SetStyledValue(AvaloniaProperty property, object value, BindingPrio
originalValue?.GetType().FullName ?? "(null)"));
}
- if (_values == null)
- {
- _values = new ValueStore(this);
- }
-
LogPropertySet(property, value, priority);
- _values.AddValue(property, value, (int)priority);
+ Values.AddValue(property, value, (int)priority);
}
///
diff --git a/src/Avalonia.Base/IPriorityValueOwner.cs b/src/Avalonia.Base/IPriorityValueOwner.cs
index 5f63f6ef91d..8cbf212381a 100644
--- a/src/Avalonia.Base/IPriorityValueOwner.cs
+++ b/src/Avalonia.Base/IPriorityValueOwner.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Avalonia.Data;
+using Avalonia.Utilities;
namespace Avalonia
{
@@ -31,5 +32,7 @@ internal interface IPriorityValueOwner
/// Ensures that the current thread is the UI thread.
///
void VerifyAccess();
+
+ DeferredSetter