37 lines
986 B
C#
37 lines
986 B
C#
using Microsoft.Extensions.Configuration;
|
|||
|
|
|
||
|
|
namespace MAF1.Plugins;
|
||
|
|
|
||
|
|
public sealed class PluginOptions
|
||
|
|
{
|
||
|
|
public string Directory { get; set; } = "plugins";
|
||
|
|
public int DefaultTimeoutSeconds { get; set; } = 180;
|
||
|
|
|
||
|
|
public string ResolveRoot()
|
||
|
|
{
|
||
|
|
if (Path.IsPathRooted(Directory))
|
||
|
|
{
|
||
|
|
return Directory;
|
||
|
|
}
|
||
|
|
|
||
|
|
return Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, Directory));
|
||
|
|
}
|
||
|
|
|
||
|
|
public static PluginOptions Load(IConfiguration config)
|
||
|
|
=> config.GetSection("Plugins").Get<PluginOptions>() ?? new PluginOptions();
|
||
|
|
}
|
||
|
|
|
||
|
|
public sealed class LoadedPlugin
|
||
|
|
{
|
||
|
|
public required string FolderName { get; init; }
|
||
|
|
public required string FolderPath { get; init; }
|
||
|
|
public required PluginContract.PluginManifest Manifest { get; init; }
|
||
|
|
}
|
||
|
|
|
||
|
|
public sealed class CatalogIssue
|
||
|
|
{
|
||
|
|
public string Level { get; init; } = "error";
|
||
|
|
public string Source { get; init; } = "";
|
||
|
|
public string Message { get; init; } = "";
|
||
|
|
}
|