|
|
@@ -5,15 +5,6 @@ using System;
|
|
|
|
|
|
namespace Avalonia.Utilities
|
|
|
{
|
|
|
- /// <summary>
|
|
|
- /// Callback invoked when deferred setter wants to set a value.
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="TValue">Value type.</typeparam>
|
|
|
- /// <param name="property">Property being set.</param>
|
|
|
- /// <param name="backing">Backing field reference.</param>
|
|
|
- /// <param name="value">New value.</param>
|
|
|
- internal delegate void SetAndNotifyCallback<TValue>(AvaloniaProperty property, ref TValue backing, TValue value);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// A utility class to enable deferring assignment until after property-changed notifications are sent.
|
|
|
/// Used to fix #855.
|
|
|
@@ -70,14 +61,14 @@ namespace Avalonia.Utilities
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public bool SetAndNotifyCallback<TValue>(AvaloniaProperty property, SetAndNotifyCallback<TValue> setAndNotifyCallback, ref TValue backing, TValue value)
|
|
|
+ public bool SetAndNotifyCallback<TValue>(AvaloniaProperty property, ISetAndNotifyHandler<TValue> setAndNotifyHandler, ref TValue backing, TValue value)
|
|
|
where TValue : TSetRecord
|
|
|
{
|
|
|
if (!_isNotifying)
|
|
|
{
|
|
|
using (new NotifyDisposable(this))
|
|
|
{
|
|
|
- setAndNotifyCallback(property, ref backing, value);
|
|
|
+ setAndNotifyHandler.HandleSetAndNotify(property, ref backing, value);
|
|
|
}
|
|
|
|
|
|
if (!_pendingValues.Empty)
|
|
|
@@ -86,7 +77,7 @@ namespace Avalonia.Utilities
|
|
|
{
|
|
|
while (!_pendingValues.Empty)
|
|
|
{
|
|
|
- setAndNotifyCallback(property, ref backing, (TValue) _pendingValues.Dequeue());
|
|
|
+ setAndNotifyHandler.HandleSetAndNotify(property, ref backing, (TValue)_pendingValues.Dequeue());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -119,4 +110,19 @@ namespace Avalonia.Utilities
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Handler for set and notify requests.
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TValue">Value type.</typeparam>
|
|
|
+ internal interface ISetAndNotifyHandler<TValue>
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// Handles deferred setter requests to set a value.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="property">Property being set.</param>
|
|
|
+ /// <param name="backing">Backing field reference.</param>
|
|
|
+ /// <param name="value">New value.</param>
|
|
|
+ void HandleSetAndNotify(AvaloniaProperty property, ref TValue backing, TValue value);
|
|
|
+ }
|
|
|
}
|