Files
community/Ink Canvas/Helpers/Plugins/PluginServiceManager.cs
T

25 lines
703 B
C#
Raw Normal View History

2025-08-24 12:02:29 +08:00
using System;
namespace Ink_Canvas.Helpers.Plugins
{
/// <summary>
2026-04-05 14:06:49 +08:00
/// 兼容旧代码的薄门面:与 <see cref="PluginSdkHostContext"/> 为同一实例,实现 <see cref="IPluginService"/>。
2025-08-24 12:02:29 +08:00
/// </summary>
2026-04-05 14:06:49 +08:00
public static class PluginServiceManager
2025-08-24 12:02:29 +08:00
{
2026-04-05 14:06:49 +08:00
public static IPluginService Instance
2025-08-24 12:02:29 +08:00
{
get
{
2026-04-05 14:06:49 +08:00
var ctx = PluginRuntime.SdkContext;
if (ctx == null)
2025-08-24 12:02:29 +08:00
{
2026-04-05 14:06:49 +08:00
throw new InvalidOperationException("插件宿主尚未初始化:请先调用 PluginRuntime.Initialize(MainWindow)。");
2025-08-24 12:02:29 +08:00
}
2026-04-05 14:06:49 +08:00
return (IPluginService)ctx;
2025-08-24 12:02:29 +08:00
}
}
}
2026-04-05 14:06:49 +08:00
}