mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-22 09:14:25 +08:00
settings_re8
This commit is contained in:
@@ -23,6 +23,7 @@ public sealed class LoadedPlugin : IDisposable, IAsyncDisposable
|
||||
IServiceProvider services,
|
||||
IReadOnlyList<PluginSettingsSectionRegistration> settingsSections,
|
||||
IReadOnlyList<PluginDesktopComponentRegistration> desktopComponents,
|
||||
IReadOnlyList<PluginDesktopComponentEditorRegistration> desktopComponentEditors,
|
||||
IReadOnlyList<PluginServiceExportDescriptor> exportedServices,
|
||||
IReadOnlyList<IHostedService> hostedServices,
|
||||
PluginLoadContext loadContext)
|
||||
@@ -36,6 +37,7 @@ public sealed class LoadedPlugin : IDisposable, IAsyncDisposable
|
||||
Services = services;
|
||||
SettingsSections = settingsSections;
|
||||
DesktopComponents = desktopComponents;
|
||||
DesktopComponentEditors = desktopComponentEditors;
|
||||
ExportedServices = exportedServices;
|
||||
HostedServices = hostedServices;
|
||||
LoadContext = loadContext;
|
||||
@@ -61,6 +63,8 @@ public sealed class LoadedPlugin : IDisposable, IAsyncDisposable
|
||||
|
||||
public IReadOnlyList<PluginDesktopComponentRegistration> DesktopComponents { get; }
|
||||
|
||||
public IReadOnlyList<PluginDesktopComponentEditorRegistration> DesktopComponentEditors { get; }
|
||||
|
||||
public IReadOnlyList<PluginServiceExportDescriptor> ExportedServices { get; }
|
||||
|
||||
public PluginLoadContext LoadContext { get; }
|
||||
|
||||
@@ -10,3 +10,7 @@ public sealed record PluginSettingsSectionContribution(
|
||||
public sealed record PluginDesktopComponentContribution(
|
||||
LoadedPlugin Plugin,
|
||||
PluginDesktopComponentRegistration Registration);
|
||||
|
||||
public sealed record PluginDesktopComponentEditorContribution(
|
||||
LoadedPlugin Plugin,
|
||||
PluginDesktopComponentEditorRegistration Registration);
|
||||
|
||||
@@ -181,10 +181,14 @@ public sealed class PluginLoader
|
||||
.OrderBy(component => component.Category, StringComparer.OrdinalIgnoreCase)
|
||||
.ThenBy(component => component.DisplayName, StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
var desktopComponentEditors = pluginServices
|
||||
.GetServices<PluginDesktopComponentEditorRegistration>()
|
||||
.OrderBy(editor => editor.ComponentId, StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
var exportedServices = ResolveExports(manifest, pluginServices);
|
||||
AppLogger.Info(
|
||||
"PluginLoader",
|
||||
$"Plugin contributions resolved. PluginId='{manifest.Id}'; SettingsSections={settingsSections.Length}; Widgets={desktopComponents.Length}; Exports={exportedServices.Count}.");
|
||||
$"Plugin contributions resolved. PluginId='{manifest.Id}'; SettingsSections={settingsSections.Length}; Widgets={desktopComponents.Length}; Editors={desktopComponentEditors.Length}; Exports={exportedServices.Count}.");
|
||||
hostedServices = pluginServices.GetServices<IHostedService>().ToArray();
|
||||
StartHostedServices(hostedServices);
|
||||
AppLogger.Info("PluginLoader", $"Hosted services started. PluginId='{manifest.Id}'; HostedServices={hostedServices.Count}.");
|
||||
@@ -199,6 +203,7 @@ public sealed class PluginLoader
|
||||
pluginServices,
|
||||
settingsSections,
|
||||
desktopComponents,
|
||||
desktopComponentEditors,
|
||||
exportedServices,
|
||||
hostedServices,
|
||||
loadContext);
|
||||
|
||||
@@ -36,6 +36,7 @@ public sealed class PluginRuntimeService : IDisposable
|
||||
private readonly List<PluginCatalogEntry> _catalog = [];
|
||||
private readonly List<PluginSettingsSectionContribution> _settingsSections = [];
|
||||
private readonly List<PluginDesktopComponentContribution> _desktopComponents = [];
|
||||
private readonly List<PluginDesktopComponentEditorContribution> _desktopComponentEditors = [];
|
||||
private readonly object _packageMutationGate = new();
|
||||
|
||||
public PluginRuntimeService(ISettingsFacadeService? settingsFacade = null)
|
||||
@@ -73,6 +74,7 @@ public sealed class PluginRuntimeService : IDisposable
|
||||
public IReadOnlyList<PluginSettingsSectionContribution> SettingsSections => _settingsSections;
|
||||
|
||||
public IReadOnlyList<PluginDesktopComponentContribution> DesktopComponents => _desktopComponents;
|
||||
public IReadOnlyList<PluginDesktopComponentEditorContribution> DesktopComponentEditors => _desktopComponentEditors;
|
||||
|
||||
public IPluginExportRegistry ExportRegistry => _exportRegistry;
|
||||
|
||||
@@ -193,7 +195,7 @@ public sealed class PluginRuntimeService : IDisposable
|
||||
loadResult.LoadedPlugin.DesktopComponents.Count));
|
||||
AppLogger.Info(
|
||||
"PluginRuntime",
|
||||
$"Plugin loaded. PluginId='{loadResult.LoadedPlugin.Manifest.Id}'; SourcePath='{loadResult.SourcePath}'; ManifestVersion='{loadResult.LoadedPlugin.Manifest.Version ?? "<unknown>"}'; ApiVersion='{loadResult.LoadedPlugin.Manifest.ApiVersion ?? "<unknown>"}'; SourceKind='{candidate.SourceKind}'; SettingsSections={loadResult.LoadedPlugin.SettingsSections.Count}; Widgets={loadResult.LoadedPlugin.DesktopComponents.Count}.");
|
||||
$"Plugin loaded. PluginId='{loadResult.LoadedPlugin.Manifest.Id}'; SourcePath='{loadResult.SourcePath}'; ManifestVersion='{loadResult.LoadedPlugin.Manifest.Version ?? "<unknown>"}'; ApiVersion='{loadResult.LoadedPlugin.Manifest.ApiVersion ?? "<unknown>"}'; SourceKind='{candidate.SourceKind}'; SettingsSections={loadResult.LoadedPlugin.SettingsSections.Count}; Widgets={loadResult.LoadedPlugin.DesktopComponents.Count}; Editors={loadResult.LoadedPlugin.DesktopComponentEditors.Count}.");
|
||||
Debug.WriteLine($"[PluginRuntime] Loaded '{loadResult.Manifest?.Id}' from '{loadResult.SourcePath}'.");
|
||||
continue;
|
||||
}
|
||||
@@ -622,6 +624,10 @@ public sealed class PluginRuntimeService : IDisposable
|
||||
entry.Plugin.Manifest.Id,
|
||||
loadedPlugin.Manifest.Id,
|
||||
StringComparison.OrdinalIgnoreCase));
|
||||
_desktopComponentEditors.RemoveAll(entry => string.Equals(
|
||||
entry.Plugin.Manifest.Id,
|
||||
loadedPlugin.Manifest.Id,
|
||||
StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
foreach (var settingsSection in loadedPlugin.SettingsSections)
|
||||
{
|
||||
@@ -632,6 +638,11 @@ public sealed class PluginRuntimeService : IDisposable
|
||||
{
|
||||
_desktopComponents.Add(new PluginDesktopComponentContribution(loadedPlugin, desktopComponent));
|
||||
}
|
||||
|
||||
foreach (var desktopComponentEditor in loadedPlugin.DesktopComponentEditors)
|
||||
{
|
||||
_desktopComponentEditors.Add(new PluginDesktopComponentEditorContribution(loadedPlugin, desktopComponentEditor));
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterSharedContractsForLoad(PluginManifest manifest)
|
||||
|
||||
Reference in New Issue
Block a user