Data model visualization - Moved services and VMs to UI.Shared

Data model visualization - Added support for custom display VMs
Data model visualization - Added framework for custom input VMs
Shared UI - Made internal converters public
This commit is contained in:
Robert committed 2020-07-02 16:04:21 +02:00
1 parent addb06c348
commit 448d94915c
30 files changed
+537 -129

No files matched your search

@@ -65,8 +65,6 @@
</ResourceDictionary>
</UserControl.Resources>
<Grid HorizontalAlignment="Stretch">
<!-- Style="{StaticResource MaterialDesignFloatingHintTextBox}" -->
<!-- Padding="0 0 10 0" -->
<TextBox x:Name="ColorCodeTextBox"
materialDesign:TextFieldAssist.TextBoxViewMargin="1 0 1 0"
Text="{Binding Color, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource ColorToStringConverter}}"
@@ -11,7 +11,7 @@ namespace Artemis.UI.Shared.Converters
/// opacity.
/// </summary>
[ValueConversion(typeof(Color), typeof(string))]
internal class ColorToSolidColorConverter : IValueConverter
public class ColorToSolidColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
@@ -10,7 +10,7 @@ namespace Artemis.UI.Shared.Converters
/// Converts <see cref="T:System.Windows.Media.Color" /> into <see cref="T:System.String" />.
/// </summary>
[ValueConversion(typeof(Color), typeof(string))]
internal class ColorToStringConverter : IValueConverter
public class ColorToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
@@ -0,0 +1,29 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using SkiaSharp;
namespace Artemis.UI.Shared.Converters
{
/// <inheritdoc />
/// <summary>
/// Converts <see cref="SKColor"/>into <see cref="T:System.String" />.
/// </summary>
[ValueConversion(typeof(Color), typeof(string))]
public class SKColorToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value?.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (string.IsNullOrWhiteSpace((string) value))
return SKColor.Empty;
return SKColor.TryParse((string)value, out var color) ? color : SKColor.Empty;
}
}
}
@@ -0,0 +1,39 @@
using Stylet;
namespace Artemis.UI.Shared.DataModelVisualization
{
public abstract class DataModelDisplayViewModel<T> : DataModelDisplayViewModel
{
private T _displayValue;
public T DisplayValue
{
get => _displayValue;
set
{
if (!SetAndNotify(ref _displayValue, value)) return;
OnDisplayValueUpdated();
}
}
protected virtual void OnDisplayValueUpdated()
{
}
internal override void UpdateValue(object model)
{
DisplayValue = model is T value ? value : default;
}
}
/// <summary>
/// For internal use only, implement <see cref="DataModelDisplayViewModel{T}" /> instead.
/// </summary>
public abstract class DataModelDisplayViewModel : PropertyChangedBase
{
/// <summary>
/// Prevents this type being implemented directly, implement <see cref="DataModelDisplayViewModel{T}" /> instead.
/// </summary>
internal abstract void UpdateValue(object model);
}
}
@@ -0,0 +1,28 @@
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Stylet;
namespace Artemis.UI.Shared.DataModelVisualization
{
public abstract class DataModelInputViewModel<T> : DataModelInputViewModel
{
protected DataModelInputViewModel(DataModelPropertyAttribute description)
{
Description = description;
}
public DataModelPropertyAttribute Description { get; }
internal override object InternalGuard { get; } = null;
}
/// <summary>
/// For internal use only, implement <see cref="DataModelInputViewModel{T}" /> instead.
/// </summary>
public abstract class DataModelInputViewModel : PropertyChangedBase
{
/// <summary>
/// Prevents this type being implemented directly, implement <see cref="DataModelInputViewModel{T}" /> instead.
/// </summary>
// ReSharper disable once UnusedMember.Global
internal abstract object InternalGuard { get; }
}
}
@@ -0,0 +1,53 @@
using System;
using Artemis.Core;
using Artemis.Core.Plugins.Models;
using Artemis.UI.Shared.Services;
namespace Artemis.UI.Shared.DataModelVisualization
{
public class DataModelVisualizationRegistration
{
private readonly IDataModelVisualizationService _dataModelVisualizationService;
public DataModelVisualizationRegistration(IDataModelVisualizationService dataModelVisualizationService,
RegistrationType registrationType,
PluginInfo pluginInfo,
Type supportedType,
Type viewModelType)
{
_dataModelVisualizationService = dataModelVisualizationService;
RegistrationType = registrationType;
PluginInfo = pluginInfo;
SupportedType = supportedType;
ViewModelType = viewModelType;
if (PluginInfo != Constants.CorePluginInfo)
PluginInfo.Instance.PluginDisabled += InstanceOnPluginDisabled;
}
public RegistrationType RegistrationType { get; }
public PluginInfo PluginInfo { get; }
public Type SupportedType { get; }
public Type ViewModelType { get; }
internal void Unsubscribe()
{
if (PluginInfo != Constants.CorePluginInfo)
PluginInfo.Instance.PluginDisabled -= InstanceOnPluginDisabled;
}
private void InstanceOnPluginDisabled(object sender, EventArgs e)
{
if (RegistrationType == RegistrationType.Input)
_dataModelVisualizationService.RemoveDataModelInput(this);
else if (RegistrationType == RegistrationType.Display)
_dataModelVisualizationService.RemoveDataModelDisplay(this);
}
}
public enum RegistrationType
{
Display,
Input
}
}
@@ -0,0 +1,79 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.UI.Shared.Services;
using Stylet;
namespace Artemis.UI.Shared.DataModelVisualization.Shared
{
public class DataModelListViewModel : DataModelVisualizationViewModel
{
private readonly IDataModelVisualizationService _dataModelVisualizationService;
private BindableCollection<DataModelVisualizationViewModel> _children;
private string _count;
private IList _list;
internal DataModelListViewModel(PropertyInfo propertyInfo, DataModelPropertyAttribute propertyDescription, DataModelVisualizationViewModel parent,
IDataModelVisualizationService dataModelVisualizationService)
{
_dataModelVisualizationService = dataModelVisualizationService;
PropertyInfo = propertyInfo;
Parent = parent;
PropertyDescription = propertyDescription;
Children = new BindableCollection<DataModelVisualizationViewModel>();
}
public BindableCollection<DataModelVisualizationViewModel> Children
{
get => _children;
set => SetAndNotify(ref _children, value);
}
public IList List
{
get => _list;
set => SetAndNotify(ref _list, value);
}
public string Count
{
get => _count;
set => SetAndNotify(ref _count, value);
}
public override void Update()
{
if (PropertyInfo != null && Parent?.Model != null && PropertyInfo.GetValue(Parent.Model) is IList listValue)
{
Model = new List<object>(listValue.Cast<object>());
List = (IList) Model;
}
var index = 0;
foreach (var item in List)
{
DataModelVisualizationViewModel child;
if (Children.Count <= index)
{
child = CreateChild(_dataModelVisualizationService, item);
Children.Add(child);
}
else
{
child = Children[index];
child.Model = item;
}
child.Update();
index++;
}
while (Children.Count > List.Count)
Children.RemoveAt(Children.Count - 1);
Count = $"{Children.Count} {(Children.Count == 1 ? "item" : "items")}";
}
}
}
@@ -0,0 +1,59 @@
using System.Reflection;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
namespace Artemis.UI.Shared.DataModelVisualization.Shared
{
public class DataModelPropertyViewModel : DataModelVisualizationViewModel
{
private DataModelDisplayViewModel _displayViewModel;
private bool _showNull;
private bool _showToString;
private bool _showViewModel;
internal DataModelPropertyViewModel(PropertyInfo propertyInfo, DataModelPropertyAttribute propertyDescription, DataModelVisualizationViewModel parent)
{
PropertyInfo = propertyInfo;
Parent = parent;
PropertyDescription = propertyDescription;
}
public DataModelDisplayViewModel DisplayViewModel
{
get => _displayViewModel;
set => SetAndNotify(ref _displayViewModel, value);
}
public bool ShowToString
{
get => _showToString;
set => SetAndNotify(ref _showToString, value);
}
public bool ShowNull
{
get => _showNull;
set => SetAndNotify(ref _showNull, value);
}
public bool ShowViewModel
{
get => _showViewModel;
set => SetAndNotify(ref _showViewModel, value);
}
public override void Update()
{
if (PropertyInfo != null && Parent?.Model != null)
{
Model = PropertyInfo.GetValue(Parent.Model);
DisplayViewModel?.UpdateValue(Model);
}
ShowToString = Model != null && DisplayViewModel == null;
ShowNull = Model == null;
ShowViewModel = Model != null && DisplayViewModel != null;
UpdateListStatus();
}
}
}
@@ -0,0 +1,60 @@
using System.Reflection;
using Artemis.Core.Extensions;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.UI.Shared.Services;
using Stylet;
namespace Artemis.UI.Shared.DataModelVisualization.Shared
{
public class DataModelViewModel : DataModelVisualizationViewModel
{
private readonly IDataModelVisualizationService _dataModelVisualizationService;
private BindableCollection<DataModelVisualizationViewModel> _children;
internal DataModelViewModel()
{
Children = new BindableCollection<DataModelVisualizationViewModel>();
}
internal DataModelViewModel(PropertyInfo propertyInfo, object model, DataModelPropertyAttribute propertyDescription, DataModelVisualizationViewModel parent,
IDataModelVisualizationService dataModelVisualizationService)
{
_dataModelVisualizationService = dataModelVisualizationService;
PropertyInfo = propertyInfo;
Model = model;
PropertyDescription = propertyDescription;
Parent = parent;
Children = new BindableCollection<DataModelVisualizationViewModel>();
PopulateProperties();
}
public BindableCollection<DataModelVisualizationViewModel> Children
{
get => _children;
set => SetAndNotify(ref _children, value);
}
public void PopulateProperties()
{
Children.Clear();
foreach (var propertyInfo in Model.GetType().GetProperties())
{
var child = CreateChild(_dataModelVisualizationService, propertyInfo);
if (child != null)
Children.Add(child);
}
}
public override void Update()
{
if (PropertyInfo != null && PropertyInfo.PropertyType.IsStruct())
Model = PropertyInfo.GetValue(Parent.Model);
foreach (var dataModelVisualizationViewModel in Children)
dataModelVisualizationViewModel.Update();
UpdateListStatus();
}
}
}
@@ -0,0 +1,136 @@
using System;
using System.Collections;
using System.Reflection;
using Artemis.Core.Extensions;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.UI.Shared.Services;
using Humanizer;
using Stylet;
namespace Artemis.UI.Shared.DataModelVisualization.Shared
{
public abstract class DataModelVisualizationViewModel : PropertyChangedBase
{
private bool _isListProperty;
private string _listDescription;
private object _model;
private DataModelVisualizationViewModel _parent;
private DataModelPropertyAttribute _propertyDescription;
private PropertyInfo _propertyInfo;
private Type _propertyType;
internal DataModelVisualizationViewModel()
{
}
public DataModelPropertyAttribute PropertyDescription
{
get => _propertyDescription;
protected set => SetAndNotify(ref _propertyDescription, value);
}
public PropertyInfo PropertyInfo
{
get => _propertyInfo;
protected set => SetAndNotify(ref _propertyInfo, value);
}
public Type PropertyType
{
get => _propertyType;
set => SetAndNotify(ref _propertyType, value);
}
public DataModelVisualizationViewModel Parent
{
get => _parent;
protected set => SetAndNotify(ref _parent, value);
}
public object Model
{
get => _model;
set => SetAndNotify(ref _model, value);
}
public bool IsListProperty
{
get => _isListProperty;
set => SetAndNotify(ref _isListProperty, value);
}
public string ListDescription
{
get => _listDescription;
set => SetAndNotify(ref _listDescription, value);
}
public abstract void Update();
protected DataModelVisualizationViewModel CreateChild(IDataModelVisualizationService dataModelVisualizationService, PropertyInfo propertyInfo)
{
// Skip properties decorated with DataModelIgnore
if (Attribute.IsDefined(propertyInfo, typeof(DataModelIgnoreAttribute)))
return null;
var dataModelPropertyAttribute = (DataModelPropertyAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(DataModelPropertyAttribute));
// If no DataModelProperty attribute was provided, pull one out of our ass
if (dataModelPropertyAttribute == null)
dataModelPropertyAttribute = new DataModelPropertyAttribute {Name = propertyInfo.Name.Humanize()};
// If a display VM was found, prefer to use that in any case
var typeViewModel = dataModelVisualizationService.GetDataModelDisplayViewModel(propertyInfo.PropertyType);
if (typeViewModel != null)
return new DataModelPropertyViewModel(propertyInfo, dataModelPropertyAttribute, this) {DisplayViewModel = typeViewModel};
// For primitives, create a property view model, it may be null that is fine
if (propertyInfo.PropertyType.IsPrimitive || propertyInfo.PropertyType == typeof(string))
return new DataModelPropertyViewModel(propertyInfo, dataModelPropertyAttribute, this);
if (typeof(IList).IsAssignableFrom(propertyInfo.PropertyType))
return new DataModelListViewModel(propertyInfo, dataModelPropertyAttribute, this, dataModelVisualizationService);
// For other value types create a child view model if the value type is not null
if (propertyInfo.PropertyType.IsClass || propertyInfo.PropertyType.IsStruct())
{
var value = propertyInfo.GetValue(Model);
if (value == null)
return null;
return new DataModelViewModel(propertyInfo, value, dataModelPropertyAttribute, this, dataModelVisualizationService);
}
return null;
}
protected DataModelVisualizationViewModel CreateChild(IDataModelVisualizationService dataModelVisualizationService, object value)
{
var dataModelPropertyAttribute = new DataModelPropertyAttribute {Name = "Unknown property"};
// If a display VM was found, prefer to use that in any case
var typeViewModel = dataModelVisualizationService.GetDataModelDisplayViewModel(value.GetType());
if (typeViewModel != null)
return new DataModelPropertyViewModel(null, dataModelPropertyAttribute, this) {Model = value, DisplayViewModel = typeViewModel};
// For primitives, create a property view model, it may be null that is fine
if (value.GetType().IsPrimitive || value is string)
return new DataModelPropertyViewModel(null, dataModelPropertyAttribute, this) {Model = value};
// For other value types create a child view model if the value type is not null
if (value.GetType().IsClass || value.GetType().IsStruct())
return new DataModelViewModel(null, value, dataModelPropertyAttribute, this, dataModelVisualizationService);
return null;
}
protected void UpdateListStatus()
{
if (Parent is DataModelListViewModel listViewModel)
{
IsListProperty = true;
ListDescription = $"List item [{listViewModel.List.IndexOf(Model)}]";
PropertyType = Model.GetType();
}
else
{
IsListProperty = false;
PropertyType = PropertyInfo?.PropertyType;
}
}
}
}
@@ -30,15 +30,10 @@ namespace Artemis.UI.Shared.PropertyInput
PluginInfo.Instance.PluginDisabled -= InstanceOnPluginDisabled;
}
internal void Remove()
{
// It'll call Unsubscribe for us
_profileEditorService.RemovePropertyInput(this);
}
private void InstanceOnPluginDisabled(object sender, EventArgs e)
{
Remove();
// Profile editor service will call Unsubscribe
_profileEditorService.RemovePropertyInput(this);
}
}
}
@@ -5,10 +5,10 @@ using Stylet;
namespace Artemis.UI.Shared.PropertyInput
{
public abstract class PropertyInputViewModel<T> : ValidatingModelBase, IDisposable
public abstract class PropertyInputViewModel<T> : PropertyInputViewModel
{
private T _inputValue;
private bool _inputDragging;
private T _inputValue;
protected PropertyInputViewModel(LayerProperty<T> layerProperty, IProfileEditorService profileEditorService)
{
@@ -30,6 +30,7 @@ namespace Artemis.UI.Shared.PropertyInput
public LayerProperty<T> LayerProperty { get; }
public IProfileEditorService ProfileEditorService { get; }
internal override object InternalGuard { get; } = null;
public bool InputDragging
{
@@ -47,12 +48,15 @@ namespace Artemis.UI.Shared.PropertyInput
}
}
public virtual void Dispose()
public override void Dispose()
{
LayerProperty.Updated -= LayerPropertyOnUpdated;
LayerProperty.BaseValueChanged -= LayerPropertyOnUpdated;
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void OnInputValueApplied()
{
}
@@ -97,7 +101,6 @@ namespace Artemis.UI.Shared.PropertyInput
Validate();
}
#region Event handlers
public void InputDragStarted(object sender, EventArgs e)
@@ -122,4 +125,33 @@ namespace Artemis.UI.Shared.PropertyInput
#endregion
}
/// <summary>
/// For internal use only, implement <see cref="PropertyInputViewModel{T}"/> instead.
/// </summary>
public abstract class PropertyInputViewModel : ValidatingModelBase, IDisposable
{
protected PropertyInputViewModel()
{
}
protected PropertyInputViewModel(IModelValidator validator) : base(validator)
{
}
/// <summary>
/// Prevents this type being implemented directly, implement <see cref="PropertyInputViewModel{T}"/> instead.
/// </summary>
// ReSharper disable once UnusedMember.Global
internal abstract object InternalGuard { get; }
public abstract void Dispose();
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
}
}
}
}
@@ -0,0 +1,144 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Shared.DataModelVisualization;
using Artemis.UI.Shared.DataModelVisualization.Shared;
using Artemis.UI.Shared.Services.Interfaces;
using Ninject;
namespace Artemis.UI.Shared.Services
{
public class DataModelVisualizationService : IDataModelVisualizationService
{
private readonly IDataModelService _dataModelService;
private readonly IKernel _kernel;
private readonly List<DataModelVisualizationRegistration> _registeredDataModelDisplays;
private readonly List<DataModelVisualizationRegistration> _registeredDataModelEditors;
public DataModelVisualizationService(IDataModelService dataModelService, IKernel kernel)
{
_dataModelService = dataModelService;
_kernel = kernel;
_registeredDataModelEditors = new List<DataModelVisualizationRegistration>();
_registeredDataModelDisplays = new List<DataModelVisualizationRegistration>();
}
public DataModelViewModel GetMainDataModelVisualization()
{
var viewModel = new DataModelViewModel();
foreach (var dataModelExpansion in _dataModelService.DataModelExpansions)
viewModel.Children.Add(new DataModelViewModel(null, dataModelExpansion, dataModelExpansion.DataModelDescription, viewModel, this));
return viewModel;
}
public DataModelViewModel GetPluginDataModelVisualization(Plugin plugin)
{
var dataModel = _dataModelService.GetPluginDataModel(plugin);
if (dataModel == null)
return null;
var viewModel = new DataModelViewModel();
viewModel.Children.Add(new DataModelViewModel(null, dataModel, dataModel.DataModelDescription, viewModel, this));
return viewModel;
}
public DataModelVisualizationRegistration RegisterDataModelInput<T>(PluginInfo pluginInfo) where T : DataModelInputViewModel
{
var viewModelType = typeof(T);
lock (_registeredDataModelEditors)
{
var supportedType = viewModelType.BaseType.GetGenericArguments()[0];
var existing = _registeredDataModelEditors.FirstOrDefault(r => r.SupportedType == supportedType);
if (existing != null)
{
if (existing.PluginInfo != pluginInfo)
throw new ArtemisPluginException($"Cannot register property editor for type {supportedType.Name} because an editor was already registered by {pluginInfo.Name}");
return existing;
}
_kernel.Bind(viewModelType).ToSelf();
var registration = new DataModelVisualizationRegistration(this, RegistrationType.Input, pluginInfo, supportedType, viewModelType);
_registeredDataModelEditors.Add(registration);
return registration;
}
}
public DataModelVisualizationRegistration RegisterDataModelDisplay<T>(PluginInfo pluginInfo) where T : DataModelDisplayViewModel
{
var viewModelType = typeof(T);
lock (_registeredDataModelDisplays)
{
var supportedType = viewModelType.BaseType.GetGenericArguments()[0];
var existing = _registeredDataModelDisplays.FirstOrDefault(r => r.SupportedType == supportedType);
if (existing != null)
{
if (existing.PluginInfo != pluginInfo)
throw new ArtemisPluginException($"Cannot register property editor for type {supportedType.Name} because an editor was already registered by {pluginInfo.Name}");
return existing;
}
_kernel.Bind(viewModelType).ToSelf();
var registration = new DataModelVisualizationRegistration(this, RegistrationType.Display, pluginInfo, supportedType, viewModelType);
_registeredDataModelDisplays.Add(registration);
return registration;
}
}
public void RemoveDataModelInput(DataModelVisualizationRegistration registration)
{
lock (_registeredDataModelEditors)
{
if (_registeredDataModelEditors.Contains(registration))
{
registration.Unsubscribe();
_registeredDataModelEditors.Remove(registration);
_kernel.Unbind(registration.ViewModelType);
}
}
}
public void RemoveDataModelDisplay(DataModelVisualizationRegistration registration)
{
lock (_registeredDataModelDisplays)
{
if (_registeredDataModelDisplays.Contains(registration))
{
registration.Unsubscribe();
_registeredDataModelDisplays.Remove(registration);
_kernel.Unbind(registration.ViewModelType);
}
}
}
public DataModelDisplayViewModel GetDataModelDisplayViewModel(Type propertyType)
{
lock (_registeredDataModelDisplays)
{
var match = _registeredDataModelDisplays.FirstOrDefault(d => d.SupportedType == propertyType);
if (match != null)
return (DataModelDisplayViewModel) _kernel.Get(match.ViewModelType);
return null;
}
}
}
public interface IDataModelVisualizationService : IArtemisSharedUIService
{
DataModelViewModel GetMainDataModelVisualization();
DataModelViewModel GetPluginDataModelVisualization(Plugin plugin);
DataModelVisualizationRegistration RegisterDataModelInput<T>(PluginInfo pluginInfo) where T : DataModelInputViewModel;
DataModelVisualizationRegistration RegisterDataModelDisplay<T>(PluginInfo pluginInfo) where T : DataModelDisplayViewModel;
void RemoveDataModelInput(DataModelVisualizationRegistration registration);
void RemoveDataModelDisplay(DataModelVisualizationRegistration registration);
DataModelDisplayViewModel GetDataModelDisplayViewModel(Type propertyType);
}
}
@@ -63,7 +63,15 @@ namespace Artemis.UI.Shared.Services.Interfaces
/// </summary>
event EventHandler ProfilePreviewUpdated;
PropertyInputRegistration RegisterPropertyInput(PluginInfo pluginInfo, Type viewModelType);
/// <summary>
/// Registers a new property input view model used in the profile editor for the generic type defined in
/// <see cref="PropertyInputViewModel{T}" />
/// <para>Note: Registration will remove itself on plugin disable so you don't have to</para>
/// </summary>
/// <param name="pluginInfo"></param>
/// <returns></returns>
PropertyInputRegistration RegisterPropertyInput<T>(PluginInfo pluginInfo) where T : PropertyInputViewModel;
void RemovePropertyInput(PropertyInputRegistration registration);
}
}
@@ -103,6 +103,7 @@ namespace Artemis.UI.Shared.Services
foreach (var baseLayerEffect in folder.LayerEffects)
baseLayerEffect.Update(delta.TotalSeconds);
}
foreach (var layer in SelectedProfile.GetAllLayers())
{
layer.OverrideProgress(CurrentTime);
@@ -153,12 +154,9 @@ namespace Artemis.UI.Shared.Services
UpdateProfilePreview();
}
public PropertyInputRegistration RegisterPropertyInput(PluginInfo pluginInfo, Type viewModelType)
public PropertyInputRegistration RegisterPropertyInput<T>(PluginInfo pluginInfo) where T : PropertyInputViewModel
{
// Bit ugly to do a name comparison but I don't know a nicer way right now
if (viewModelType.BaseType == null || viewModelType.BaseType.Name != typeof(PropertyInputViewModel<>).Name)
throw new ArtemisPluginException($"{nameof(viewModelType)} base type must be of type PropertyInputViewModel<T>");
var viewModelType = typeof(T);
lock (_registeredPropertyEditors)
{
var supportedType = viewModelType.BaseType.GetGenericArguments()[0];