mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Core - Remove API versioning, we have MinimumVersion to achieve the same thing
This commit is contained in:
1 parent
e2cb73e327
commit
86f2426f37
184 files changed
+598
-523
No files matched your search
@@ -14,7 +14,7 @@ internal sealed class SurfaceManager : IDisposable
|
||||
{
|
||||
private readonly IRenderer _renderer;
|
||||
private readonly TimerUpdateTrigger _updateTrigger;
|
||||
private readonly List<ArtemisDevice> _devices = new();
|
||||
private readonly List<ArtemisDevice> _devices = [];
|
||||
private readonly SKTextureBrush _textureBrush = new(null) {CalculationMode = RenderMode.Absolute};
|
||||
|
||||
private ListLedGroup? _surfaceLedGroup;
|
||||
@@ -44,7 +44,7 @@ internal sealed class SurfaceManager : IDisposable
|
||||
|
||||
public void AddDevices(IEnumerable<ArtemisDevice> devices)
|
||||
{
|
||||
List<IRGBDevice> newDevices = new();
|
||||
List<IRGBDevice> newDevices = [];
|
||||
lock (_devices)
|
||||
{
|
||||
foreach (ArtemisDevice artemisDevice in devices)
|
||||
@@ -66,7 +66,7 @@ internal sealed class SurfaceManager : IDisposable
|
||||
|
||||
public void RemoveDevices(IEnumerable<ArtemisDevice> devices)
|
||||
{
|
||||
List<IRGBDevice> removedDevices = new();
|
||||
List<IRGBDevice> removedDevices = [];
|
||||
lock (_devices)
|
||||
{
|
||||
foreach (ArtemisDevice artemisDevice in devices)
|
||||
|
||||
@@ -100,7 +100,7 @@ internal class InputService : IInputService
|
||||
|
||||
#region Providers
|
||||
|
||||
private readonly List<InputProvider> _inputProviders = new();
|
||||
private readonly List<InputProvider> _inputProviders = [];
|
||||
|
||||
public KeyboardToggleStatus KeyboardToggleStatus { get; private set; } = new(false, false, false);
|
||||
|
||||
@@ -137,7 +137,7 @@ internal class InputService : IInputService
|
||||
#region Identification
|
||||
|
||||
private readonly Dictionary<Tuple<InputProvider, object>, ArtemisDevice> _deviceCache = new();
|
||||
private List<ArtemisDevice> _devices = new();
|
||||
private List<ArtemisDevice> _devices = [];
|
||||
private ArtemisDevice? _identifyingDevice;
|
||||
|
||||
public void IdentifyDevice(ArtemisDevice device)
|
||||
@@ -308,7 +308,7 @@ internal class InputService : IInputService
|
||||
if (device != null)
|
||||
{
|
||||
// Ensure the device is in the dictionary
|
||||
_pressedKeys.TryAdd(device, new HashSet<KeyboardKey>());
|
||||
_pressedKeys.TryAdd(device, []);
|
||||
// Get the hash set of the device
|
||||
HashSet<KeyboardKey> pressedDeviceKeys = _pressedKeys[device];
|
||||
// See if the key is already pressed
|
||||
@@ -389,7 +389,7 @@ internal class InputService : IInputService
|
||||
|
||||
#region Mouse
|
||||
|
||||
private readonly HashSet<MouseButton> _pressedButtons = new();
|
||||
private readonly HashSet<MouseButton> _pressedButtons = [];
|
||||
|
||||
|
||||
private void InputProviderOnMouseButtonDataReceived(object? sender, InputProviderMouseButtonEventArgs e)
|
||||
|
||||
@@ -21,12 +21,12 @@ public interface IPluginManagementService : IArtemisService, IDisposable
|
||||
/// Indicates whether or not plugins are currently being loaded
|
||||
/// </summary>
|
||||
bool LoadingPlugins { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether or not plugins are currently loaded
|
||||
/// </summary>
|
||||
bool LoadedPlugins { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Loads all installed plugins. If plugins already loaded this will reload them all
|
||||
/// </summary>
|
||||
@@ -108,7 +108,13 @@ public interface IPluginManagementService : IArtemisService, IDisposable
|
||||
void DisablePluginFeature(PluginFeature pluginFeature, bool saveState);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin info of all loaded plugins
|
||||
/// Gets the plugin info of all plugins, regardless of whether they are currently loaded
|
||||
/// </summary>
|
||||
/// <returns>A list containing all the plugin info</returns>
|
||||
List<PluginInfo> GetAllPluginInfo();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of all loaded plugins
|
||||
/// </summary>
|
||||
/// <returns>A list containing all the plugin info</returns>
|
||||
List<Plugin> GetAllPlugins();
|
||||
@@ -149,7 +155,7 @@ public interface IPluginManagementService : IArtemisService, IDisposable
|
||||
/// <param name="device"></param>
|
||||
/// <returns></returns>
|
||||
DeviceProvider GetDeviceProviderByDevice(IRGBDevice device);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a plugin has started loading
|
||||
/// </summary>
|
||||
@@ -183,7 +189,7 @@ public interface IPluginManagementService : IArtemisService, IDisposable
|
||||
/// <summary>
|
||||
/// Occurs when a plugin is removed
|
||||
/// </summary>
|
||||
event EventHandler<PluginEventArgs> PluginRemoved;
|
||||
event EventHandler<PluginEventArgs> PluginRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a plugin feature is being enabled
|
||||
|
||||
@@ -28,6 +28,7 @@ internal class PluginManagementService : IPluginManagementService
|
||||
private readonly IContainer _container;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPluginRepository _pluginRepository;
|
||||
private readonly List<PluginInfo> _pluginInfos;
|
||||
private readonly List<Plugin> _plugins;
|
||||
private FileSystemWatcher? _hotReloadWatcher;
|
||||
private bool _disposed;
|
||||
@@ -39,20 +40,29 @@ internal class PluginManagementService : IPluginManagementService
|
||||
_logger = logger;
|
||||
_pluginRepository = pluginRepository;
|
||||
_deviceRepository = deviceRepository;
|
||||
_plugins = new List<Plugin>();
|
||||
_pluginInfos = [];
|
||||
_plugins = [];
|
||||
}
|
||||
|
||||
public List<DirectoryInfo> AdditionalPluginDirectories { get; } = new();
|
||||
public List<DirectoryInfo> AdditionalPluginDirectories { get; } = [];
|
||||
|
||||
public bool LoadingPlugins { get; private set; }
|
||||
|
||||
public bool LoadedPlugins { get; private set; }
|
||||
|
||||
public List<PluginInfo> GetAllPluginInfo()
|
||||
{
|
||||
lock (_pluginInfos)
|
||||
{
|
||||
return [.._pluginInfos];
|
||||
}
|
||||
}
|
||||
|
||||
public List<Plugin> GetAllPlugins()
|
||||
{
|
||||
lock (_plugins)
|
||||
{
|
||||
return new List<Plugin>(_plugins);
|
||||
return [.._plugins];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +273,13 @@ internal class PluginManagementService : IPluginManagementService
|
||||
if (_plugins.Any(p => p.Guid == pluginInfo.Guid))
|
||||
throw new ArtemisCoreException($"Cannot load plugin {pluginInfo} because it is using a GUID already used by another plugin");
|
||||
}
|
||||
|
||||
// There may be info on a plugin that previously failed to load, remove that
|
||||
lock (_pluginInfos)
|
||||
{
|
||||
_pluginInfos.RemoveAll(i => i.Guid == pluginInfo.Guid);
|
||||
_pluginInfos.Add(pluginInfo);
|
||||
}
|
||||
|
||||
// Load the entity and fall back on creating a new one
|
||||
PluginEntity? entity = _pluginRepository.GetPluginByPluginGuid(pluginInfo.Guid);
|
||||
@@ -301,6 +318,7 @@ internal class PluginManagementService : IPluginManagementService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pluginInfo.LoadException = e;
|
||||
throw new ArtemisPluginException(plugin, "Failed to load the plugins assembly", e);
|
||||
}
|
||||
|
||||
@@ -312,6 +330,7 @@ internal class PluginManagementService : IPluginManagementService
|
||||
}
|
||||
catch (ReflectionTypeLoadException e)
|
||||
{
|
||||
pluginInfo.LoadException = e;
|
||||
throw new ArtemisPluginException(
|
||||
plugin,
|
||||
"Failed to initialize the plugin assembly",
|
||||
@@ -471,6 +490,10 @@ internal class PluginManagementService : IPluginManagementService
|
||||
}
|
||||
|
||||
plugin.Dispose();
|
||||
lock (_pluginInfos)
|
||||
{
|
||||
_pluginInfos.Remove(plugin.Info);
|
||||
}
|
||||
lock (_plugins)
|
||||
{
|
||||
_plugins.Remove(plugin);
|
||||
|
||||
@@ -28,7 +28,7 @@ public static partial class ProcessMonitor
|
||||
get
|
||||
{
|
||||
lock (LOCK)
|
||||
return _processes.Values.ToImmutableArray();
|
||||
return [.._processes.Values];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Artemis.Core.Services;
|
||||
internal class RenderService : IRenderService, IRenderer, IDisposable
|
||||
{
|
||||
private readonly Stopwatch _frameStopWatch;
|
||||
private readonly List<Exception> _updateExceptions = new();
|
||||
private readonly List<Exception> _updateExceptions = [];
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDeviceService _deviceService;
|
||||
|
||||
@@ -8,8 +8,8 @@ internal class SurfaceArrangement
|
||||
{
|
||||
public SurfaceArrangement()
|
||||
{
|
||||
Types = new List<SurfaceArrangementType>();
|
||||
ArrangedDevices = new List<ArtemisDevice>();
|
||||
Types = [];
|
||||
ArrangedDevices = [];
|
||||
}
|
||||
|
||||
public List<SurfaceArrangementType> Types { get; }
|
||||
|
||||
@@ -12,7 +12,7 @@ internal class SurfaceArrangementType
|
||||
SurfaceArrangement = surfaceArrangement;
|
||||
DeviceType = deviceType;
|
||||
ZIndex = zIndex;
|
||||
Configurations = new List<SurfaceArrangementConfiguration>();
|
||||
Configurations = [];
|
||||
}
|
||||
|
||||
public SurfaceArrangement SurfaceArrangement { get; }
|
||||
|
||||
@@ -23,9 +23,9 @@ internal class ProfileService : IProfileService
|
||||
private readonly IProfileRepository _profileRepository;
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly IDeviceService _deviceService;
|
||||
private readonly List<ArtemisKeyboardKeyEventArgs> _pendingKeyboardEvents = new();
|
||||
private readonly List<Exception> _renderExceptions = new();
|
||||
private readonly List<Exception> _updateExceptions = new();
|
||||
private readonly List<ArtemisKeyboardKeyEventArgs> _pendingKeyboardEvents = [];
|
||||
private readonly List<Exception> _renderExceptions = [];
|
||||
private readonly List<Exception> _updateExceptions = [];
|
||||
|
||||
private DateTime _lastRenderExceptionLog;
|
||||
private DateTime _lastUpdateExceptionLog;
|
||||
|
||||
@@ -55,7 +55,7 @@ public abstract class PluginEndPoint
|
||||
public FlexibleContentType Returns { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Occurs whenever a request threw an unhandled exception
|
||||
/// Occurs whenever a request threw an Unhandled error
|
||||
/// </summary>
|
||||
public event EventHandler<EndpointExceptionEventArgs>? RequestException;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
{
|
||||
_logger = logger;
|
||||
_coreService = coreService;
|
||||
_controllers = new List<WebApiControllerRegistration>();
|
||||
_controllers = [];
|
||||
|
||||
_webServerEnabledSetting = settingsService.GetSetting("WebServer.Enabled", true);
|
||||
_webServerRemoteAccessSetting = settingsService.GetSetting("WebServer.RemoteAccess", false);
|
||||
|
||||
Reference in new issue
Block a user