mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Data model - Added data model visualization view model
Debugger - Split debugger into different tabs Debugger - Added data model debugger
This commit is contained in:
1 parent
1bc8d65237
commit
98ec26304a
33 files changed
+565
-236
No files matched your search
@@ -1,23 +1,39 @@
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
||||
using FastMember;
|
||||
|
||||
namespace Artemis.UI.DataModelVisualization
|
||||
{
|
||||
public class DataModelPropertyViewModel : DataModelVisualizationViewModel
|
||||
public class DataModelPropertyViewModel<T, TP> : DataModelPropertyViewModel
|
||||
{
|
||||
private readonly ObjectAccessor _accessor;
|
||||
private readonly Func<T, TP> _expression;
|
||||
|
||||
public DataModelPropertyViewModel(PropertyInfo propertyInfo, DataModelPropertyAttribute propertyDescription, DataModelViewModel parent)
|
||||
{
|
||||
_accessor = ObjectAccessor.Create(parent.Model);
|
||||
|
||||
PropertyInfo = propertyInfo;
|
||||
Parent = parent;
|
||||
PropertyDescription = propertyDescription;
|
||||
|
||||
var instance = Expression.Parameter(typeof(T), "instance");
|
||||
var body = Expression.Property(instance, propertyInfo);
|
||||
_expression = Expression.Lambda<Func<T, TP>>(body, instance).Compile();
|
||||
}
|
||||
|
||||
public PropertyInfo PropertyInfo { get; }
|
||||
public object Value => _accessor[PropertyInfo.Name];
|
||||
public TP Value
|
||||
{
|
||||
get => BaseValue is TP value ? value : default;
|
||||
set => BaseValue = value;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
Value = _expression((T) Parent.Model);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class DataModelPropertyViewModel : DataModelVisualizationViewModel
|
||||
{
|
||||
public object BaseValue { get; protected set; }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user