Browse Source
We already have some specific internal methods for routing certain methods via an untyped property to a typed property, but adding support for the visitor pattern allows us to support arbitrary use-cases.pull/3636/head
5 changed files with 63 additions and 0 deletions
@ -0,0 +1,34 @@ |
|||||
|
#nullable enable |
||||
|
|
||||
|
namespace Avalonia.Utilities |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// A visitor to resolve an untyped <see cref="AvaloniaProperty"/> to a typed property.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TData">The type of user data passed.</typeparam>
|
||||
|
/// <remarks>
|
||||
|
/// Pass an instance that implements this interface to
|
||||
|
/// <see cref="AvaloniaProperty.Accept{TData}(IAvaloniaPropertyVisitor{TData}, ref TData)"/>
|
||||
|
/// in order to resolve un untyped <see cref="AvaloniaProperty"/> to a typed
|
||||
|
/// <see cref="StyledPropertyBase{TValue}"/> or <see cref="DirectPropertyBase{TValue}"/>.
|
||||
|
/// </remarks>
|
||||
|
public interface IAvaloniaPropertyVisitor<TData> |
||||
|
where TData : struct |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Called when the property is a styled property.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="T">The property value type.</typeparam>
|
||||
|
/// <param name="property">The property.</param>
|
||||
|
/// <param name="data">The user data.</param>
|
||||
|
void Visit<T>(StyledPropertyBase<T> property, ref TData data); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Called when the property is a direct property.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="T">The property value type.</typeparam>
|
||||
|
/// <param name="property">The property.</param>
|
||||
|
/// <param name="data">The user data.</param>
|
||||
|
void Visit<T>(DirectPropertyBase<T> property, ref TData data); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue