diff --git a/src/Avalonia.Base/AvaloniaObject.cs b/src/Avalonia.Base/AvaloniaObject.cs
index baca1494be..1b7bd91a8f 100644
--- a/src/Avalonia.Base/AvaloniaObject.cs
+++ b/src/Avalonia.Base/AvaloniaObject.cs
@@ -32,8 +32,7 @@ namespace Avalonia
///
/// The set values/bindings on this object.
///
- private readonly Dictionary _values =
- new Dictionary();
+ private readonly ValueStore _values;
///
/// Maintains a list of direct property binding subscriptions so that the binding source
@@ -73,6 +72,8 @@ namespace Avalonia
{
VerifyAccess();
+ _values = new ValueStore(this);
+
void Notify(AvaloniaProperty property)
{
object value = property.IsDirect ?
@@ -230,7 +231,7 @@ namespace Avalonia
}
else
{
- return GetValueInternal(property);
+ return _values.GetValue(property);
}
}
@@ -257,7 +258,7 @@ namespace Avalonia
Contract.Requires(property != null);
VerifyAccess();
- return _values.TryGetValue(property, out PriorityValue value) ? value.IsAnimating : false;
+ return _values.IsAnimating(property);
}
///
@@ -274,14 +275,7 @@ namespace Avalonia
Contract.Requires(property != null);
VerifyAccess();
- PriorityValue value;
-
- if (_values.TryGetValue(property, out value))
- {
- return value.Value != AvaloniaProperty.UnsetValue;
- }
-
- return false;
+ return _values.IsSet(property);
}
///
@@ -369,14 +363,6 @@ namespace Avalonia
}
else
{
- PriorityValue v;
-
- if (!_values.TryGetValue(property, out v))
- {
- v = CreatePriorityValue(property);
- _values.Add(property, v);
- }
-
Logger.Verbose(
LogArea.Property,
this,
@@ -385,7 +371,7 @@ namespace Avalonia
description,
priority);
- return v.Add(source, (int)priority);
+ return _values.AddBinding(property, source, priority);
}
}
@@ -416,20 +402,12 @@ namespace Avalonia
public void Revalidate(AvaloniaProperty property)
{
VerifyAccess();
- PriorityValue value;
-
- if (_values.TryGetValue(property, out value))
- {
- value.Revalidate();
- }
+ _values.Revalidate(property);
}
///
- void IPriorityValueOwner.Changed(PriorityValue sender, object oldValue, object newValue)
+ void IPriorityValueOwner.Changed(AvaloniaProperty property, int priority, object oldValue, object newValue)
{
- var property = sender.Property;
- var priority = (BindingPriority)sender.ValuePriority;
-
oldValue = (oldValue == AvaloniaProperty.UnsetValue) ?
GetDefaultValue(property) :
oldValue;
@@ -439,7 +417,7 @@ namespace Avalonia
if (!Equals(oldValue, newValue))
{
- RaisePropertyChanged(property, oldValue, newValue, priority);
+ RaisePropertyChanged(property, oldValue, newValue, (BindingPriority)priority);
Logger.Verbose(
LogArea.Property,
@@ -448,14 +426,14 @@ namespace Avalonia
property,
oldValue,
newValue,
- priority);
+ (BindingPriority)priority);
}
}
///
- void IPriorityValueOwner.BindingNotificationReceived(PriorityValue sender, BindingNotification notification)
+ void IPriorityValueOwner.BindingNotificationReceived(AvaloniaProperty property, BindingNotification notification)
{
- UpdateDataValidation(sender.Property, notification);
+ UpdateDataValidation(property, notification);
}
///
@@ -468,10 +446,7 @@ namespace Avalonia
/// Gets all priority values set on the object.
///
/// A collection of property/value tuples.
- internal IDictionary GetSetValues()
- {
- return _values;
- }
+ internal IDictionary GetSetValues() => _values.GetSetValues();
///
/// Forces revalidation of properties when a property value changes.
@@ -660,68 +635,18 @@ namespace Avalonia
}
}
- ///
- /// Creates a for a .
- ///
- /// The property.
- /// The .
- private PriorityValue CreatePriorityValue(AvaloniaProperty property)
- {
- var validate = ((IStyledPropertyAccessor)property).GetValidationFunc(GetType());
- Func