Plugins - Simplified and streamlined the way plugins provide VMs

Plugins - Added dependency injection to all plugin VMs
Plugin settings - Allow injecting plugin settings into any class defined in the plugin assembly
This commit is contained in:
Robert committed 2020-08-21 20:22:46 +02:00
1 parent a06ad8f011
commit 625fcbafdd
29 files changed
+349 -165

No files matched your search

@@ -2,6 +2,7 @@
using Artemis.Core.Exceptions;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Repositories.Interfaces;
using Ninject.Activation;
@@ -10,20 +11,28 @@ namespace Artemis.Core.Ninject
internal class PluginSettingsProvider : Provider<PluginSettings>
{
private readonly IPluginRepository _pluginRepository;
private readonly IPluginService _pluginService;
internal PluginSettingsProvider(IPluginRepository pluginRepository)
internal PluginSettingsProvider(IPluginRepository pluginRepository, IPluginService pluginService)
{
_pluginRepository = pluginRepository;
_pluginService = pluginService;
}
protected override PluginSettings CreateInstance(IContext context)
{
var parentRequest = context.Request.ParentRequest;
if (parentRequest == null || !typeof(Plugin).IsAssignableFrom(parentRequest.Service))
throw new ArtemisCoreException("PluginSettings can only be injected into a plugin");
if (parentRequest == null)
throw new ArtemisCoreException("PluginSettings couldn't be injected, failed to get the injection parent request");
// First try by PluginInfo parameter
var pluginInfo = parentRequest.Parameters.FirstOrDefault(p => p.Name == "PluginInfo")?.GetValue(context, null) as PluginInfo;
if (pluginInfo == null)
throw new ArtemisCoreException("A plugin needs to be initialized with PluginInfo as a parameter");
pluginInfo = _pluginService.GetPluginByAssembly(parentRequest.Service.Assembly)?.PluginInfo;
// Fall back to assembly based detection
if (pluginInfo == null)
throw new ArtemisCoreException("PluginSettings can only be injected with the PluginInfo parameter provided " +
"or into a class defined in a plugin assembly");
return new PluginSettings(pluginInfo, _pluginRepository);
}
@@ -13,21 +13,38 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary>
public abstract class DeviceProvider : Plugin
{
/// <summary>
/// Creates a new instance of the <see cref="DeviceProvider" /> class
/// </summary>
/// <param name="rgbDeviceProvider"></param>
protected DeviceProvider(IRGBDeviceProvider rgbDeviceProvider)
{
RgbDeviceProvider = rgbDeviceProvider ?? throw new ArgumentNullException(nameof(rgbDeviceProvider));
}
/// <summary>
/// The RGB.NET device provider backing this Artemis device provider
/// </summary>
public IRGBDeviceProvider RgbDeviceProvider { get; }
/// <summary>
/// TODO: Make internal while still injecting.
/// A logger used by the device provider internally, ignore this
/// </summary>
[Inject]
public ILogger Logger { get; set; }
/// <inheritdoc />
public override void DisablePlugin()
{
// Does not happen with device providers, they require Artemis to restart
}
/// <summary>
/// </summary>
/// <param name="type"></param>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ResolveAbsolutePath(Type type, object sender, ResolvePathEventArgs e)
{
if (sender.GetType() == type || sender.GetType().IsGenericType(type))
@@ -7,14 +7,16 @@ using Artemis.Core.Plugins.LayerBrush.Abstract;
namespace Artemis.Core.Plugins.Abstract
{
/// <inheritdoc />
/// <summary>
/// Allows you to create one or more <see cref="LayerBrush" />s usable by profile layers.
/// Allows you to create one or more <see cref="LayerBrush{T}" />s usable by profile layers.
/// </summary>
public abstract class LayerBrushProvider : Plugin
{
private readonly List<LayerBrushDescriptor> _layerBrushDescriptors;
/// <summary>
/// Allows you to register one or more <see cref="LayerBrush{T}" />s usable by profile layers.
/// </summary>
protected LayerBrushProvider()
{
_layerBrushDescriptors = new List<LayerBrushDescriptor>();
@@ -7,14 +7,16 @@ using Artemis.Core.Plugins.LayerEffect.Abstract;
namespace Artemis.Core.Plugins.Abstract
{
/// <inheritdoc />
/// <summary>
/// Allows you to create one or more <see cref="LayerEffect" />s usable by profile layers.
/// Allows you to register one or more <see cref="LayerEffect{T}" />s usable by profile layers.
/// </summary>
public abstract class LayerEffectProvider : Plugin
{
private readonly List<LayerEffectDescriptor> _layerEffectDescriptors;
/// <summary>
/// Allows you to register one or more <see cref="LayerEffect{T}" />s usable by profile layers.
/// </summary>
protected LayerEffectProvider()
{
_layerEffectDescriptors = new List<LayerEffectDescriptor>();
+15 -11
View File
@@ -4,7 +4,6 @@ using System.Linq;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract.DataModels;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Modules;
using Artemis.Storage.Entities.Module;
using SkiaSharp;
@@ -104,20 +103,25 @@ namespace Artemis.Core.Plugins.Abstract
public ModulePriorityCategory DefaultPriorityCategory { get; set; } = ModulePriorityCategory.Normal;
/// <summary>
/// Gets or sets the current priority category of this module
/// Gets the current priority category of this module
/// </summary>
public ModulePriorityCategory PriorityCategory { get; set; }
public ModulePriorityCategory PriorityCategory { get; internal set; }
/// <summary>
/// Gets or sets the current priority of this module within its priority category
/// Gets the current priority of this module within its priority category
/// </summary>
public int Priority { get; set; }
public int Priority { get; internal set; }
internal DataModel InternalDataModel { get; set; }
internal bool InternalExpandsMainDataModel { get; set; }
internal ModuleSettingsEntity Entity { get; set; }
/// <summary>
/// A list of custom module tabs that show in the UI
/// </summary>
public IEnumerable<ModuleTab> ModuleTabs { get; protected set; }
/// <summary>
/// Called each frame when the module must update
/// </summary>
@@ -133,12 +137,6 @@ namespace Artemis.Core.Plugins.Abstract
/// <param name="canvasInfo"></param>
public abstract void Render(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo);
/// <summary>
/// Called when the module's view model is being show, return a list of module tabs here if you want them to show up in the UI
/// </summary>
/// <returns></returns>
public abstract IEnumerable<ModuleTab> GetModuleTabs();
/// <summary>
/// Called when the <see cref="ActivationRequirements" /> are met
/// </summary>
@@ -194,6 +192,9 @@ namespace Artemis.Core.Plugins.Abstract
}
}
/// <summary>
/// Describes in what way the activation requirements of a module must be met
/// </summary>
public enum ActivationRequirementType
{
/// <summary>
@@ -207,6 +208,9 @@ namespace Artemis.Core.Plugins.Abstract
All
}
/// <summary>
/// Describes the priority category of a module
/// </summary>
public enum ModulePriorityCategory
{
/// <summary>
+20 -15
View File
@@ -3,7 +3,6 @@ using System.Threading.Tasks;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.Models;
using Castle.Core.Internal;
namespace Artemis.Core.Plugins.Abstract
{
@@ -12,19 +11,22 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary>
public abstract class Plugin : IDisposable
{
/// <summary>
/// Gets the plugin info related to this plugin
/// </summary>
public PluginInfo PluginInfo { get; internal set; }
/// <summary>
/// Gets whether the plugin is enabled
/// </summary>
public bool Enabled { get; private set; }
/// <summary>
/// Gets or sets whether this plugin has a configuration view model.
/// If set to true, <see cref="GetConfigurationViewModel" /> will be called when the plugin is configured from the UI.
/// Gets or sets a configuration dialog for this plugin that is accessible in the UI under Settings > Plugins
/// </summary>
public bool HasConfigurationViewModel { get; protected set; }
public PluginConfigurationDialog ConfigurationDialog { get; protected set; }
/// <inheritdoc />
public void Dispose()
{
DisablePlugin();
@@ -40,16 +42,6 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary>
public abstract void DisablePlugin();
/// <summary>
/// Called when the plugins configuration window is opened from the UI. The UI will only attempt to open if
/// <see cref="HasConfigurationViewModel" /> is set to True.
/// </summary>
/// <returns></returns>
public virtual PluginConfigurationViewModel GetConfigurationViewModel()
{
return null;
}
internal void SetEnabled(bool enable, bool isAutoEnable = false)
{
if (enable && !Enabled)
@@ -116,14 +108,27 @@ namespace Artemis.Core.Plugins.Abstract
#region Events
/// <summary>
/// Occurs when the plugin is enabled
/// </summary>
public event EventHandler PluginEnabled;
/// <summary>
/// Occurs when the plugin is disabled
/// </summary>
public event EventHandler PluginDisabled;
/// <summary>
/// Triggers the PluginEnabled event
/// </summary>
protected virtual void OnPluginEnabled()
{
PluginEnabled?.Invoke(this, EventArgs.Empty);
}
/// <summary>
/// Triggers the PluginDisabled event
/// </summary>
protected virtual void OnPluginDisabled()
{
PluginDisabled?.Invoke(this, EventArgs.Empty);
@@ -0,0 +1,28 @@
using System;
using Artemis.Core.Plugins.Abstract.ViewModels;
namespace Artemis.Core.Plugins.Abstract
{
/// <inheritdoc />
public class PluginConfigurationDialog<T> : PluginConfigurationDialog where T : PluginConfigurationViewModel
{
/// <inheritdoc />
public override Type Type => typeof(T);
}
/// <summary>
/// Describes a configuration dialog for a specific plugin
/// </summary>
public abstract class PluginConfigurationDialog
{
/// <summary>
/// The layer brush this dialog belongs to
/// </summary>
internal Plugin Plugin { get; set; }
/// <summary>
/// The type of view model the tab contains
/// </summary>
public abstract Type Type { get; }
}
}
@@ -1,6 +1,5 @@
using System;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
@@ -15,6 +14,7 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
public abstract class BaseLayerBrush : PropertyChangedBase, IDisposable
{
private LayerBrushType _brushType;
private LayerBrushConfigurationDialog _configurationDialog;
private LayerBrushDescriptor _descriptor;
private Layer _layer;
private bool _supportsTransformation = true;
@@ -37,6 +37,15 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
internal set => SetAndNotify(ref _descriptor, value);
}
/// <summary>
/// Gets or sets a configuration dialog complementing the regular properties
/// </summary>
public LayerBrushConfigurationDialog ConfigurationDialog
{
get => _configurationDialog;
protected set => SetAndNotify(ref _configurationDialog, value);
}
/// <summary>
/// Gets the type of layer brush
/// </summary>
@@ -71,17 +80,12 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
}
}
/// <summary>
/// Gets or sets whether this plugin has a configuration view model.
/// If set to true, <see cref="GetConfigurationViewModel" /> will be called when the plugin is configured from the UI.
/// </summary>
public bool HasConfigurationViewModel { get; protected set; }
/// <inheritdoc />
public void Dispose()
{
DisableLayerBrush();
BaseProperties.Dispose();
Dispose(true);
GC.SuppressFinalize(this);
}
@@ -102,16 +106,6 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
/// <param name="deltaTime">Seconds passed since last update</param>
public abstract void Update(double deltaTime);
/// <summary>
/// Called when the brush configuration window is opened from the UI. The UI will only attempt to open if
/// <see cref="HasConfigurationViewModel" /> is set to True.
/// </summary>
/// <returns></returns>
public virtual BrushConfigurationViewModel GetConfigurationViewModel()
{
return null;
}
// Not only is this needed to initialize properties on the layer brushes, it also prevents implementing anything
// but LayerBrush<T> and RgbNetLayerBrush<T> outside the core
internal abstract void Initialize(IRenderElementService renderElementService);
@@ -123,9 +117,19 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
}
}
/// <summary>
/// Describes the type of a layer brush
/// </summary>
public enum LayerBrushType
{
/// <summary>
/// A regular brush that users Artemis' SkiaSharp-based rendering engine
/// </summary>
Regular,
/// <summary>
/// An RGB.NET brush that uses RGB.NET's per-LED rendering engine.
/// </summary>
RgbNet
}
}
@@ -8,8 +8,16 @@ using SkiaSharp;
namespace Artemis.Core.Plugins.LayerBrush.Abstract
{
/// <summary>
/// An RGB.NET brush that uses RGB.NET's per-LED rendering engine.
/// <para>Note: This brush type always renders on top of regular brushes</para>
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class RgbNetLayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup
{
/// <summary>
/// Creates a new instance of the <see cref="RgbNetLayerBrush{T}" /> class
/// </summary>
protected RgbNetLayerBrush()
{
BrushType = LayerBrushType.RgbNet;
@@ -0,0 +1,29 @@
using System;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.LayerBrush.Abstract;
namespace Artemis.Core.Plugins.LayerBrush
{
/// <inheritdoc />
public class LayerBrushConfigurationDialog<T> : LayerBrushConfigurationDialog where T : BrushConfigurationViewModel
{
/// <inheritdoc />
public override Type Type => typeof(T);
}
/// <summary>
/// Describes a UI tab for a layer brush
/// </summary>
public abstract class LayerBrushConfigurationDialog
{
/// <summary>
/// The layer brush this dialog belongs to
/// </summary>
internal BaseLayerBrush LayerBrush { get; set; }
/// <summary>
/// The type of view model the tab contains
/// </summary>
public abstract Type Type { get; }
}
}
@@ -3,6 +3,9 @@ using Artemis.Core.Plugins.Abstract;
namespace Artemis.Core.Plugins.LayerBrush
{
/// <summary>
/// A class that describes a layer brush
/// </summary>
public class LayerBrushDescriptor
{
internal LayerBrushDescriptor(string displayName, string description, string icon, Type layerBrushType, LayerBrushProvider layerBrushProvider)
@@ -14,10 +17,30 @@ namespace Artemis.Core.Plugins.LayerBrush
LayerBrushProvider = layerBrushProvider;
}
/// <summary>
/// The name that is displayed in the UI
/// </summary>
public string DisplayName { get; }
/// <summary>
/// The description that is displayed in the UI
/// </summary>
public string Description { get; }
/// <summary>
/// The Material icon to display in the UI, a full reference can be found
/// <see href="https://materialdesignicons.com">here</see>
/// </summary>
public string Icon { get; }
/// <summary>
/// The type of the layer brush
/// </summary>
public Type LayerBrushType { get; }
/// <summary>
/// The plugin that provided this <see cref="LayerBrushDescriptor" />
/// </summary>
public LayerBrushProvider LayerBrushProvider { get; }
}
}
@@ -1,6 +1,5 @@
using System;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using SkiaSharp;
@@ -13,13 +12,14 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
/// </summary>
public abstract class BaseLayerEffect : PropertyChangedBase, IDisposable
{
private Guid _entityId;
private RenderProfileElement _profileElement;
private string _name;
private bool _enabled;
private bool _hasBeenRenamed;
private int _order;
private LayerEffectDescriptor _descriptor;
private bool _enabled;
private Guid _entityId;
private bool _hasBeenRenamed;
private string _name;
private int _order;
private RenderProfileElement _profileElement;
private LayerEffectConfigurationDialog _configurationDialog;
/// <summary>
/// Gets the unique ID of this effect
@@ -77,7 +77,7 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
}
/// <summary>
/// Gets the descriptor of this effect
/// Gets the <see cref="LayerEffectDescriptor"/> that registered this effect
/// </summary>
public LayerEffectDescriptor Descriptor
{
@@ -85,6 +85,15 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
internal set => SetAndNotify(ref _descriptor, value);
}
/// <summary>
/// Gets or sets a configuration dialog complementing the regular properties
/// </summary>
public LayerEffectConfigurationDialog ConfigurationDialog
{
get => _configurationDialog;
protected set => SetAndNotify(ref _configurationDialog, value);
}
/// <summary>
/// Gets the plugin info that defined this effect
/// </summary>
@@ -97,12 +106,7 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
internal string PropertyRootPath => $"LayerEffect.{EntityId}.{GetType().Name}.";
/// <summary>
/// Gets or sets whether this plugin has a configuration view model.
/// If set to true, <see cref="GetConfigurationViewModel" /> will be called when the plugin is configured from the UI.
/// </summary>
public bool HasConfigurationViewModel { get; protected set; }
/// <inheritdoc />
public void Dispose()
{
DisableLayerEffect();
@@ -146,16 +150,5 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
// Not only is this needed to initialize properties on the layer effects, it also prevents implementing anything
// but LayerEffect<T> outside the core
internal abstract void Initialize(IRenderElementService renderElementService);
/// <summary>
/// Called when the effect configuration window is opened from the UI. The UI will only attempt to open if
/// <see cref="HasConfigurationViewModel" /> is set to True.
/// </summary>
/// <returns></returns>
public virtual EffectConfigurationViewModel GetConfigurationViewModel()
{
return null;
}
}
}
@@ -0,0 +1,29 @@
using System;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.LayerEffect.Abstract;
namespace Artemis.Core.Plugins.LayerEffect
{
/// <inheritdoc />
public class LayerEffectConfigurationDialog<T> : LayerEffectConfigurationDialog where T : EffectConfigurationViewModel
{
/// <inheritdoc />
public override Type Type => typeof(T);
}
/// <summary>
/// Describes a UI tab for a specific layer effect
/// </summary>
public abstract class LayerEffectConfigurationDialog
{
/// <summary>
/// The layer effect this dialog belongs to
/// </summary>
internal BaseLayerEffect LayerEffect { get; set; }
/// <summary>
/// The type of view model the tab contains
/// </summary>
public abstract Type Type { get; }
}
}
@@ -3,6 +3,9 @@ using Artemis.Core.Plugins.Abstract;
namespace Artemis.Core.Plugins.LayerEffect
{
/// <summary>
/// A class that describes a layer effect
/// </summary>
public class LayerEffectDescriptor
{
internal LayerEffectDescriptor(string displayName, string description, string icon, Type layerEffectType, LayerEffectProvider layerEffectProvider)
@@ -14,10 +17,30 @@ namespace Artemis.Core.Plugins.LayerEffect
LayerEffectProvider = layerEffectProvider;
}
/// <summary>
/// The name that is displayed in the UI
/// </summary>
public string DisplayName { get; }
/// <summary>
/// The description that is displayed in the UI
/// </summary>
public string Description { get; }
/// <summary>
/// The Material icon to display in the UI, a full reference can be found
/// <see href="https://materialdesignicons.com">here</see>
/// </summary>
public string Icon { get; }
/// <summary>
/// The type of the layer effect
/// </summary>
public Type LayerEffectType { get; }
/// <summary>
/// The plugin that provided this <see cref="LayerEffectDescriptor" />
/// </summary>
public LayerEffectProvider LayerEffectProvider { get; }
}
}
@@ -46,6 +46,12 @@ namespace Artemis.Core.Plugins.Models
}
var pluginSetting = new PluginSetting<T>(_pluginInfo, _pluginRepository, settingEntity);
// This overrides null with the default value, I'm not sure if that's desirable because you
// might expect something to go null and you might not
// if (pluginSetting.Value == null && defaultValue != null)
// pluginSetting.Value = defaultValue;
_settingEntities.Add(name, pluginSetting);
return pluginSetting;
}
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Artemis.Core.Events;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
@@ -75,7 +76,19 @@ namespace Artemis.Core.Services.Interfaces
/// <returns>Returns a list of plug instances of type <see cref="T" /></returns>
List<T> GetPluginsOfType<T>() where T : Plugin;
Plugin GetDevicePlugin(IRGBDevice device);
/// <summary>
/// Gets the plugin that provided the specified assembly
/// </summary>
/// <param name="assembly"></param>
/// <returns></returns>
Plugin GetPluginByAssembly(Assembly assembly);
/// <summary>
/// Gets the plugin that defined the specified device
/// </summary>
/// <param name="device"></param>
/// <returns></returns>
Plugin GetPluginByDevice(IRGBDevice device);
#region Events
+6 -9
View File
@@ -46,10 +46,8 @@ namespace Artemis.Core.Services
Directory.CreateDirectory(Constants.DataFolder + "plugins");
}
/// <inheritdoc />
public bool LoadingPlugins { get; private set; }
/// <inheritdoc />
public void CopyBuiltInPlugins()
{
OnCopyingBuildInPlugins();
@@ -161,7 +159,6 @@ namespace Artemis.Core.Services
}
}
/// <inheritdoc />
public void UnloadPlugins()
{
lock (_plugins)
@@ -181,7 +178,6 @@ namespace Artemis.Core.Services
}
}
/// <inheritdoc />
public void LoadPlugin(PluginInfo pluginInfo)
{
lock (_plugins)
@@ -256,7 +252,6 @@ namespace Artemis.Core.Services
}
}
/// <inheritdoc />
public void UnloadPlugin(PluginInfo pluginInfo)
{
lock (_plugins)
@@ -347,25 +342,27 @@ namespace Artemis.Core.Services
OnPluginDisabled(new PluginEventArgs(plugin.PluginInfo));
}
/// <inheritdoc />
public PluginInfo GetPluginInfo(Plugin plugin)
{
return _plugins.FirstOrDefault(p => p.Instance == plugin);
}
/// <inheritdoc />
public List<PluginInfo> GetAllPluginInfo()
{
return new List<PluginInfo>(_plugins);
}
/// <inheritdoc />
public List<T> GetPluginsOfType<T>() where T : Plugin
{
return _plugins.Where(p => p.Enabled && p.Instance is T).Select(p => (T) p.Instance).ToList();
}
public Plugin GetDevicePlugin(IRGBDevice rgbDevice)
public Plugin GetPluginByAssembly(Assembly assembly)
{
return _plugins.FirstOrDefault(p => p.Assembly == assembly)?.Instance;
}
public Plugin GetPluginByDevice(IRGBDevice rgbDevice)
{
return GetPluginsOfType<DeviceProvider>().First(d => d.RgbDeviceProvider.Devices != null && d.RgbDeviceProvider.Devices.Contains(rgbDevice));
}
@@ -50,7 +50,7 @@ namespace Artemis.Core.Services.Storage
// Add all current devices
foreach (var rgbDevice in _rgbService.LoadedDevices)
{
var plugin = _pluginService.GetDevicePlugin(rgbDevice);
var plugin = _pluginService.GetPluginByDevice(rgbDevice);
configuration.Devices.Add(new ArtemisDevice(rgbDevice, plugin, configuration));
}
@@ -142,7 +142,7 @@ namespace Artemis.Core.Services.Storage
var device = _rgbService.Surface.Devices.FirstOrDefault(d => d.GetDeviceIdentifier() == position.DeviceIdentifier);
if (device != null)
{
var plugin = _pluginService.GetDevicePlugin(device);
var plugin = _pluginService.GetPluginByDevice(device);
surfaceConfiguration.Devices.Add(new ArtemisDevice(device, plugin, surfaceConfiguration, position));
}
}
@@ -184,7 +184,7 @@ namespace Artemis.Core.Services.Storage
var existingDeviceConfig = surface.SurfaceEntity.DeviceEntities.FirstOrDefault(d => d.DeviceIdentifier == deviceIdentifier);
if (existingDeviceConfig != null)
{
var plugin = _pluginService.GetDevicePlugin(rgbDevice);
var plugin = _pluginService.GetPluginByDevice(rgbDevice);
device = new ArtemisDevice(rgbDevice, plugin, surface, existingDeviceConfig);
}
// Fall back on creating a new device
@@ -195,7 +195,7 @@ namespace Artemis.Core.Services.Storage
rgbDevice.DeviceInfo,
deviceIdentifier
);
var plugin = _pluginService.GetDevicePlugin(rgbDevice);
var plugin = _pluginService.GetPluginByDevice(rgbDevice);
device = new ArtemisDevice(rgbDevice, plugin, surface);
}
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Artemis.Core.Extensions;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Modules;
using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Storage.Entities.Profile;
using Newtonsoft.Json;
@@ -91,10 +88,5 @@ namespace Artemis.Core.Utilities
{
throw new NotImplementedException();
}
public override IEnumerable<ModuleTab> GetModuleTabs()
{
throw new NotImplementedException();
}
}
}