implement plugins section
This commit is contained in:
29
TorchRemote.Plugin/Utils/PluginManifestUtils.cs
Normal file
29
TorchRemote.Plugin/Utils/PluginManifestUtils.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Xml.Serialization;
|
||||
using Torch;
|
||||
|
||||
namespace TorchRemote.Plugin.Utils;
|
||||
|
||||
public static class PluginManifestUtils
|
||||
{
|
||||
private static readonly XmlSerializer Serializer = new(typeof(PluginManifest));
|
||||
|
||||
public static PluginManifest Read(Stream stream)
|
||||
{
|
||||
return (PluginManifest)Serializer.Deserialize(stream);
|
||||
}
|
||||
|
||||
public static PluginManifest ReadFromZip(Stream stream)
|
||||
{
|
||||
using var archive = new ZipArchive(stream);
|
||||
using var entryStream = archive.GetEntry("manifest.xml")!.Open();
|
||||
return Read(entryStream);
|
||||
}
|
||||
|
||||
public static PluginManifest ReadFromZip(string archivePath)
|
||||
{
|
||||
using var stream = File.OpenRead(archivePath);
|
||||
return ReadFromZip(stream);
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@ using Torch;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Commands;
|
||||
using Torch.Managers;
|
||||
using Torch.Server;
|
||||
using Torch.Server.Managers;
|
||||
using TorchRemote.Plugin.Managers;
|
||||
@@ -18,6 +19,7 @@ internal static class Statics
|
||||
public static readonly JsonSerializerOptions SerializerOptions = new(JsonSerializerDefaults.Web);
|
||||
public static SettingManager SettingManager => Torch.Managers.GetManager<SettingManager>();
|
||||
public static InstanceManager InstanceManager => Torch.Managers.GetManager<InstanceManager>();
|
||||
public static PluginManager PluginManager => Torch.Managers.GetManager<PluginManager>();
|
||||
public static CommandManager? CommandManager => Torch.CurrentSession?.Managers.GetManager<CommandManager>();
|
||||
|
||||
public static ChatModule ChatModule = null!;
|
||||
|
Reference in New Issue
Block a user