1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Artemis/src/Artemis.UI.Shared/DataModelVisualization/DataModelVisualizationRegistration.cs
SpoinkyNL 8718d01eae Core - Flattened namespaces
Shared UI - Flattened namespaces
Shared UI - General housekeeping
Project - Code cleanup
2020-09-01 00:14:08 +02:00

55 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using Artemis.Core;
using Artemis.UI.Shared.Services;
namespace Artemis.UI.Shared
{
public class DataModelVisualizationRegistration
{
private readonly IDataModelUIService _dataModelUIService;
public DataModelVisualizationRegistration(IDataModelUIService dataModelUIService,
RegistrationType registrationType,
PluginInfo pluginInfo,
Type supportedType,
Type viewModelType)
{
_dataModelUIService = dataModelUIService;
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; }
public IReadOnlyCollection<Type> CompatibleConversionTypes { get; internal set; }
internal void Unsubscribe()
{
if (PluginInfo != Constants.CorePluginInfo)
PluginInfo.Instance.PluginDisabled -= InstanceOnPluginDisabled;
}
private void InstanceOnPluginDisabled(object sender, EventArgs e)
{
if (RegistrationType == RegistrationType.Input)
_dataModelUIService.RemoveDataModelInput(this);
else if (RegistrationType == RegistrationType.Display)
_dataModelUIService.RemoveDataModelDisplay(this);
}
}
public enum RegistrationType
{
Display,
Input
}
}