mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Core - Added XML comments to all remaining public members/methods
Core - Refactored a lot of code for nullable reference types
This commit is contained in:
1 parent
61fc96742d
commit
a3cd32f6c4
107 files changed
+1150
-649
No files matched your search
@@ -198,7 +198,7 @@ namespace Artemis.Core.Services
|
||||
module.InternalRender(args.DeltaTime, _surfaceService.ActiveSurface, canvas, _rgbService.BitmapBrush.Bitmap.Info);
|
||||
}
|
||||
|
||||
OnFrameRendering(new FrameRenderingEventArgs(modules, canvas, args.DeltaTime, _rgbService.Surface));
|
||||
OnFrameRendering(new FrameRenderingEventArgs(canvas, args.DeltaTime, _rgbService.Surface));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -44,6 +44,10 @@ namespace Artemis.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin to enable</param>
|
||||
/// <param name="saveState">Whether or not to save the new enabled state</param>
|
||||
/// <param name="ignorePluginLock">
|
||||
/// Whether or not plugin lock files should be ignored. If set to <see langword="true" />,
|
||||
/// plugins with lock files will load successfully
|
||||
/// </param>
|
||||
void EnablePlugin(Plugin plugin, bool saveState, bool ignorePluginLock = false);
|
||||
|
||||
/// <summary>
|
||||
@@ -95,7 +99,7 @@ namespace Artemis.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
/// <returns></returns>
|
||||
Plugin GetPluginByAssembly(Assembly assembly);
|
||||
Plugin? GetPluginByAssembly(Assembly? assembly);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the plugin info of the current call stack
|
||||
|
||||
@@ -138,8 +138,10 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
public Plugin? GetPluginByAssembly(Assembly assembly)
|
||||
public Plugin? GetPluginByAssembly(Assembly? assembly)
|
||||
{
|
||||
if (assembly == null)
|
||||
return null;
|
||||
lock (_plugins)
|
||||
{
|
||||
return _plugins.FirstOrDefault(p => p.Assembly == assembly);
|
||||
@@ -159,8 +161,8 @@ namespace Artemis.Core.Services
|
||||
|
||||
foreach (StackFrame stackFrame in stackFrames)
|
||||
{
|
||||
Assembly assembly = stackFrame.GetMethod().DeclaringType.Assembly;
|
||||
Plugin plugin = GetPluginByAssembly(assembly);
|
||||
Assembly? assembly = stackFrame.GetMethod()?.DeclaringType?.Assembly;
|
||||
Plugin? plugin = GetPluginByAssembly(assembly);
|
||||
if (plugin != null)
|
||||
return plugin;
|
||||
}
|
||||
@@ -179,7 +181,7 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
if (LoadingPlugins)
|
||||
throw new ArtemisCoreException("Cannot load plugins while a previous load hasn't been completed yet.");
|
||||
|
||||
|
||||
LoadingPlugins = true;
|
||||
|
||||
// Unload all currently loaded plugins first
|
||||
@@ -207,8 +209,10 @@ namespace Artemis.Core.Services
|
||||
public void UnloadPlugins()
|
||||
{
|
||||
// Unload all plugins
|
||||
// ReSharper disable InconsistentlySynchronizedField - UnloadPlugin will lock it when it has to
|
||||
while (_plugins.Count > 0)
|
||||
UnloadPlugin(_plugins[0]);
|
||||
// ReSharper restore InconsistentlySynchronizedField
|
||||
|
||||
lock (_plugins)
|
||||
{
|
||||
@@ -297,7 +301,11 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
catch (ReflectionTypeLoadException e)
|
||||
{
|
||||
throw new ArtemisPluginException(plugin, "Failed to initialize the plugin assembly", new AggregateException(e.LoaderExceptions));
|
||||
throw new ArtemisPluginException(
|
||||
plugin,
|
||||
"Failed to initialize the plugin assembly",
|
||||
new AggregateException(e.LoaderExceptions.Where(le => le != null).Cast<Exception>().ToArray())
|
||||
);
|
||||
}
|
||||
|
||||
if (!featureTypes.Any())
|
||||
@@ -318,7 +326,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
// Load the enabled state and if not found, default to true
|
||||
instance.Entity = plugin.Entity.Features.FirstOrDefault(i => i.Type == featureType.FullName) ??
|
||||
new PluginFeatureEntity {IsEnabled = true, Type = featureType.FullName};
|
||||
new PluginFeatureEntity {IsEnabled = true, Type = featureType.FullName!};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -385,7 +393,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
plugin.SetEnabled(false);
|
||||
|
||||
plugin.Kernel.Dispose();
|
||||
plugin.Kernel?.Dispose();
|
||||
plugin.Kernel = null;
|
||||
|
||||
GC.Collect();
|
||||
@@ -487,28 +495,22 @@ namespace Artemis.Core.Services
|
||||
_pluginRepository.SavePlugin(plugin.Entity);
|
||||
}
|
||||
|
||||
private PluginFeatureEntity GetOrCreateFeatureEntity(PluginFeature feature)
|
||||
{
|
||||
return feature.Plugin.Entity.Features.FirstOrDefault(i => i.Type == feature.GetType().FullName) ??
|
||||
new PluginFeatureEntity {IsEnabled = true, Type = feature.GetType().FullName};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler CopyingBuildInPlugins;
|
||||
public event EventHandler<PluginEventArgs> PluginLoading;
|
||||
public event EventHandler<PluginEventArgs> PluginLoaded;
|
||||
public event EventHandler<PluginEventArgs> PluginUnloaded;
|
||||
public event EventHandler<PluginEventArgs> PluginEnabling;
|
||||
public event EventHandler<PluginEventArgs> PluginEnabled;
|
||||
public event EventHandler<PluginEventArgs> PluginDisabled;
|
||||
public event EventHandler? CopyingBuildInPlugins;
|
||||
public event EventHandler<PluginEventArgs>? PluginLoading;
|
||||
public event EventHandler<PluginEventArgs>? PluginLoaded;
|
||||
public event EventHandler<PluginEventArgs>? PluginUnloaded;
|
||||
public event EventHandler<PluginEventArgs>? PluginEnabling;
|
||||
public event EventHandler<PluginEventArgs>? PluginEnabled;
|
||||
public event EventHandler<PluginEventArgs>? PluginDisabled;
|
||||
|
||||
public event EventHandler<PluginFeatureEventArgs> PluginFeatureEnabling;
|
||||
public event EventHandler<PluginFeatureEventArgs> PluginFeatureEnabled;
|
||||
public event EventHandler<PluginFeatureEventArgs> PluginFeatureDisabled;
|
||||
public event EventHandler<PluginFeatureEventArgs> PluginFeatureEnableFailed;
|
||||
public event EventHandler<PluginFeatureEventArgs>? PluginFeatureEnabling;
|
||||
public event EventHandler<PluginFeatureEventArgs>? PluginFeatureEnabled;
|
||||
public event EventHandler<PluginFeatureEventArgs>? PluginFeatureDisabled;
|
||||
public event EventHandler<PluginFeatureEventArgs>? PluginFeatureEnableFailed;
|
||||
|
||||
protected virtual void OnCopyingBuildInPlugins()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.Core.DeviceProviders;
|
||||
using Artemis.Storage.Entities.Surface;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
@@ -44,8 +45,8 @@ namespace Artemis.Core.Services
|
||||
// Add all current devices
|
||||
foreach (IRGBDevice rgbDevice in _rgbService.LoadedDevices)
|
||||
{
|
||||
PluginFeature pluginFeature = _pluginManagementService.GetDeviceProviderByDevice(rgbDevice);
|
||||
configuration.Devices.Add(new ArtemisDevice(rgbDevice, pluginFeature, configuration));
|
||||
DeviceProvider deviceProvider = _pluginManagementService.GetDeviceProviderByDevice(rgbDevice);
|
||||
configuration.Devices.Add(new ArtemisDevice(rgbDevice, deviceProvider, configuration));
|
||||
}
|
||||
|
||||
lock (_surfaceConfigurations)
|
||||
@@ -136,8 +137,8 @@ namespace Artemis.Core.Services
|
||||
IRGBDevice device = _rgbService.Surface.Devices.FirstOrDefault(d => d.GetDeviceIdentifier() == position.DeviceIdentifier);
|
||||
if (device != null)
|
||||
{
|
||||
PluginFeature pluginFeature = _pluginManagementService.GetDeviceProviderByDevice(device);
|
||||
surfaceConfiguration.Devices.Add(new ArtemisDevice(device, pluginFeature, surfaceConfiguration, position));
|
||||
DeviceProvider deviceProvider = _pluginManagementService.GetDeviceProviderByDevice(device);
|
||||
surfaceConfiguration.Devices.Add(new ArtemisDevice(device, deviceProvider, surfaceConfiguration, position));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,8 +179,8 @@ namespace Artemis.Core.Services
|
||||
DeviceEntity existingDeviceConfig = surface.SurfaceEntity.DeviceEntities.FirstOrDefault(d => d.DeviceIdentifier == deviceIdentifier);
|
||||
if (existingDeviceConfig != null)
|
||||
{
|
||||
PluginFeature pluginFeature = _pluginManagementService.GetDeviceProviderByDevice(rgbDevice);
|
||||
device = new ArtemisDevice(rgbDevice, pluginFeature, surface, existingDeviceConfig);
|
||||
DeviceProvider deviceProvider = _pluginManagementService.GetDeviceProviderByDevice(rgbDevice);
|
||||
device = new ArtemisDevice(rgbDevice, deviceProvider, surface, existingDeviceConfig);
|
||||
}
|
||||
// Fall back on creating a new device
|
||||
else
|
||||
@@ -189,8 +190,8 @@ namespace Artemis.Core.Services
|
||||
rgbDevice.DeviceInfo,
|
||||
deviceIdentifier
|
||||
);
|
||||
PluginFeature pluginFeature = _pluginManagementService.GetDeviceProviderByDevice(rgbDevice);
|
||||
device = new ArtemisDevice(rgbDevice, pluginFeature, surface);
|
||||
DeviceProvider deviceProvider = _pluginManagementService.GetDeviceProviderByDevice(rgbDevice);
|
||||
device = new ArtemisDevice(rgbDevice, deviceProvider, surface);
|
||||
}
|
||||
|
||||
surface.Devices.Add(device);
|
||||
|
||||
Reference in new issue
Block a user