mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Allow plugins to opt out of hot reloading
This commit is contained in:
parent
0c44e4ba22
commit
8a0a162429
@ -28,6 +28,7 @@ public class PluginInfo : CorePropertyChanged, IPrerequisitesSubject
|
|||||||
private string _version = null!;
|
private string _version = null!;
|
||||||
private Uri? _website;
|
private Uri? _website;
|
||||||
private Uri? _helpPage;
|
private Uri? _helpPage;
|
||||||
|
private bool _hotReloadSupported;
|
||||||
|
|
||||||
internal PluginInfo()
|
internal PluginInfo()
|
||||||
{
|
{
|
||||||
@ -156,6 +157,17 @@ public class PluginInfo : CorePropertyChanged, IPrerequisitesSubject
|
|||||||
internal set => SetAndNotify(ref _requiresAdmin, value);
|
internal set => SetAndNotify(ref _requiresAdmin, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a boolean indicating whether hot reloading this plugin is supported
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(true)]
|
||||||
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||||
|
public bool HotReloadSupported
|
||||||
|
{
|
||||||
|
get => _hotReloadSupported;
|
||||||
|
set => SetAndNotify(ref _hotReloadSupported, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets
|
/// Gets
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -962,24 +962,24 @@ internal class PluginManagementService : IPluginManagementService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!plugin.Info.HotReloadSupported)
|
||||||
|
{
|
||||||
|
_logger.Information("Plugin change detected, but hot reload not supported. {pluginName}", plugin.Info.Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.Information("Plugin change detected, reloading. {pluginName}", plugin.Info.Name);
|
_logger.Information("Plugin change detected, reloading. {pluginName}", plugin.Info.Name);
|
||||||
bool wasEnabled = plugin.IsEnabled;
|
bool wasEnabled = plugin.IsEnabled;
|
||||||
|
|
||||||
UnloadPlugin(plugin);
|
UnloadPlugin(plugin);
|
||||||
|
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
|
|
||||||
Plugin? loadedPlugin = LoadPlugin(pluginDirectory);
|
Plugin? loadedPlugin = LoadPlugin(pluginDirectory);
|
||||||
|
|
||||||
if (loadedPlugin == null)
|
if (loadedPlugin == null)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (wasEnabled)
|
if (wasEnabled)
|
||||||
{
|
|
||||||
EnablePlugin(loadedPlugin, true, false);
|
EnablePlugin(loadedPlugin, true, false);
|
||||||
}
|
|
||||||
|
|
||||||
_logger.Information("Plugin reloaded. {fullPath}", e.FullPath);
|
_logger.Information("Plugin reloaded. {fullPath}", e.FullPath);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user