|
|
|
@ -1,13 +1,17 @@ |
|
|
|
using System; |
|
|
|
using Avalonia.Data; |
|
|
|
using Avalonia.Media; |
|
|
|
|
|
|
|
namespace Avalonia.Diagnostics.ViewModels |
|
|
|
{ |
|
|
|
internal class AvaloniaPropertyViewModel : PropertyViewModel |
|
|
|
{ |
|
|
|
private readonly AvaloniaObject _target; |
|
|
|
private System.Type _assignedType; |
|
|
|
private Type _assignedType; |
|
|
|
private object? _value; |
|
|
|
private string _priority; |
|
|
|
private string _group; |
|
|
|
private readonly System.Type _propertyType; |
|
|
|
private readonly Type _propertyType; |
|
|
|
|
|
|
|
#nullable disable |
|
|
|
// Remove "nullable disable" after MemberNotNull will work on our CI.
|
|
|
|
@ -28,13 +32,9 @@ namespace Avalonia.Diagnostics.ViewModels |
|
|
|
public AvaloniaProperty Property { get; } |
|
|
|
public override object Key => Property; |
|
|
|
public override string Name { get; } |
|
|
|
public override bool? IsAttached => |
|
|
|
Property.IsAttached; |
|
|
|
|
|
|
|
public override string Priority => |
|
|
|
_priority; |
|
|
|
|
|
|
|
public override System.Type AssignedType => _assignedType; |
|
|
|
public override bool? IsAttached => Property.IsAttached; |
|
|
|
public override string Priority => _priority; |
|
|
|
public override Type AssignedType => _assignedType; |
|
|
|
|
|
|
|
public override string? Value |
|
|
|
{ |
|
|
|
@ -53,30 +53,58 @@ namespace Avalonia.Diagnostics.ViewModels |
|
|
|
|
|
|
|
public override string Group => _group; |
|
|
|
|
|
|
|
public override System.Type? DeclaringType { get; } |
|
|
|
public override System.Type PropertyType => _propertyType; |
|
|
|
public override Type? DeclaringType { get; } |
|
|
|
public override Type PropertyType => _propertyType; |
|
|
|
|
|
|
|
// [MemberNotNull(nameof(_type), nameof(_group), nameof(_priority))]
|
|
|
|
public override void Update() |
|
|
|
{ |
|
|
|
if (Property.IsDirect) |
|
|
|
{ |
|
|
|
RaiseAndSetIfChanged(ref _value, _target.GetValue(Property), nameof(Value)); |
|
|
|
RaiseAndSetIfChanged(ref _assignedType,_value?.GetType() ?? Property.PropertyType, nameof(AssignedType)); |
|
|
|
object? value; |
|
|
|
Type? valueType = null; |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
value = _target.GetValue(Property); |
|
|
|
valueType = value?.GetType(); |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
value = e.GetBaseException(); |
|
|
|
} |
|
|
|
|
|
|
|
RaiseAndSetIfChanged(ref _value, value, nameof(Value)); |
|
|
|
RaiseAndSetIfChanged(ref _assignedType, valueType ?? Property.PropertyType, nameof(AssignedType)); |
|
|
|
RaiseAndSetIfChanged(ref _priority, "Direct", nameof(Priority)); |
|
|
|
|
|
|
|
_group = "Properties"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var val = _target.GetDiagnostic(Property); |
|
|
|
object? value; |
|
|
|
Type? valueType = null; |
|
|
|
BindingPriority? priority = null; |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
var diag = _target.GetDiagnostic(Property); |
|
|
|
|
|
|
|
value = diag.Value; |
|
|
|
valueType = value?.GetType(); |
|
|
|
priority = diag.Priority; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
value = e.GetBaseException(); |
|
|
|
} |
|
|
|
|
|
|
|
RaiseAndSetIfChanged(ref _value, val?.Value, nameof(Value)); |
|
|
|
RaiseAndSetIfChanged(ref _assignedType, _value?.GetType() ?? Property.PropertyType, nameof(AssignedType)); |
|
|
|
RaiseAndSetIfChanged(ref _value, value, nameof(Value)); |
|
|
|
RaiseAndSetIfChanged(ref _assignedType, valueType ?? Property.PropertyType, nameof(AssignedType)); |
|
|
|
|
|
|
|
if (val != null) |
|
|
|
if (priority != null) |
|
|
|
{ |
|
|
|
RaiseAndSetIfChanged(ref _priority, val.Priority.ToString(), nameof(Priority)); |
|
|
|
RaiseAndSetIfChanged(ref _priority, priority.ToString()!, nameof(Priority)); |
|
|
|
RaiseAndSetIfChanged(ref _group, IsAttached == true ? "Attached Properties" : "Properties", nameof(Group)); |
|
|
|
} |
|
|
|
else |
|
|
|
|