setting_re3

This commit is contained in:
lincube
2026-03-13 09:10:00 +08:00
parent c4df243610
commit 3b3f060f33
70 changed files with 1986 additions and 8966 deletions

View File

@@ -0,0 +1,21 @@
using System.Collections.Generic;
namespace LanMountainDesktop.PluginSdk;
public interface IPluginSettingsService
{
string PluginId { get; }
IComponentSettingsAccessor GetComponentAccessor(string componentId, string? placementId);
T LoadComponentSection<T>(string componentId, string? placementId, string sectionId) where T : new();
void SaveComponentSection<T>(
string componentId,
string? placementId,
string sectionId,
T section,
IReadOnlyCollection<string>? changedKeys = null);
void DeleteComponentSection(string componentId, string? placementId, string sectionId);
}

View File

@@ -10,7 +10,8 @@ public sealed class PluginDesktopComponentContext
IReadOnlyDictionary<string, object?> properties,
string componentId,
string? placementId,
double cellSize)
double cellSize,
IPluginSettingsService? pluginSettings = null)
{
ArgumentNullException.ThrowIfNull(manifest);
ArgumentException.ThrowIfNullOrWhiteSpace(pluginDirectory);
@@ -27,6 +28,7 @@ public sealed class PluginDesktopComponentContext
ComponentId = componentId.Trim();
PlacementId = string.IsNullOrWhiteSpace(placementId) ? null : placementId.Trim();
CellSize = Math.Max(1, cellSize);
PluginSettings = pluginSettings;
}
public PluginManifest Manifest { get; }
@@ -45,6 +47,8 @@ public sealed class PluginDesktopComponentContext
public double CellSize { get; }
public IPluginSettingsService? PluginSettings { get; }
public T? GetService<T>()
{
return (T?)Services.GetService(typeof(T));