Implement IPluginMetadata interface in PluginBase for enhanced plugin metadata management

This commit is contained in:
Thorsten Sommer 2025-03-23 12:35:46 +01:00
parent cc2f11f4e7
commit e10cf4171b
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 121 additions and 37 deletions

View File

@ -0,0 +1,64 @@
namespace AIStudio.Tools.PluginSystem;
public interface IPluginMetadata
{
/// <summary>
/// The type of this plugin.
/// </summary>
public PluginType Type { get; }
/// <summary>
/// The ID of this plugin.
/// </summary>
public Guid Id { get; }
/// <summary>
/// The name of this plugin.
/// </summary>
public string Name { get; }
/// <summary>
/// The description of this plugin.
/// </summary>
public string Description { get; }
/// <summary>
/// The version of this plugin.
/// </summary>
public PluginVersion Version { get; }
/// <summary>
/// The authors of this plugin.
/// </summary>
public string[] Authors { get; }
/// <summary>
/// The support contact for this plugin.
/// </summary>
public string SupportContact { get; }
/// <summary>
/// The source URL of this plugin.
/// </summary>
public string SourceURL { get; }
/// <summary>
/// The categories of this plugin.
/// </summary>
public PluginCategory[] Categories { get; }
/// <summary>
/// The target groups of this plugin.
/// </summary>
public PluginTargetGroup[] TargetGroups { get; }
/// <summary>
/// True, when the plugin is maintained.
/// </summary>
public bool IsMaintained { get; }
/// <summary>
/// The message that should be displayed when the plugin is deprecated.
/// </summary>
public string? DeprecationMessage { get; }
}

View File

@ -7,71 +7,47 @@ namespace AIStudio.Tools.PluginSystem;
/// <summary> /// <summary>
/// Represents the base of any AI Studio plugin. /// Represents the base of any AI Studio plugin.
/// </summary> /// </summary>
public abstract class PluginBase public abstract class PluginBase : IPluginMetadata
{ {
private readonly IReadOnlyCollection<string> baseIssues; private readonly IReadOnlyCollection<string> baseIssues;
protected readonly LuaState state; protected readonly LuaState state;
protected readonly List<string> pluginIssues = []; protected readonly List<string> pluginIssues = [];
/// <summary> /// <inheritdoc />
/// The type of this plugin.
/// </summary>
public PluginType Type { get; } public PluginType Type { get; }
/// <summary> /// <inheritdoc />
/// The ID of this plugin.
/// </summary>
public Guid Id { get; } public Guid Id { get; }
/// <summary> /// <inheritdoc />
/// The name of this plugin.
/// </summary>
public string Name { get; } = string.Empty; public string Name { get; } = string.Empty;
/// <summary> /// <inheritdoc />
/// The description of this plugin.
/// </summary>
public string Description { get; } = string.Empty; public string Description { get; } = string.Empty;
/// <summary> /// <inheritdoc />
/// The version of this plugin.
/// </summary>
public PluginVersion Version { get; } public PluginVersion Version { get; }
/// <summary> /// <inheritdoc />
/// The authors of this plugin.
/// </summary>
public string[] Authors { get; } = []; public string[] Authors { get; } = [];
/// <summary> /// <inheritdoc />
/// The support contact for this plugin.
/// </summary>
public string SupportContact { get; } = string.Empty; public string SupportContact { get; } = string.Empty;
/// <summary> /// <inheritdoc />
/// The source URL of this plugin.
/// </summary>
public string SourceURL { get; } = string.Empty; public string SourceURL { get; } = string.Empty;
/// <summary> /// <inheritdoc />
/// The categories of this plugin.
/// </summary>
public PluginCategory[] Categories { get; } = []; public PluginCategory[] Categories { get; } = [];
/// <summary> /// <inheritdoc />
/// The target groups of this plugin.
/// </summary>
public PluginTargetGroup[] TargetGroups { get; } = []; public PluginTargetGroup[] TargetGroups { get; } = [];
/// <summary> /// <inheritdoc />
/// True, when the plugin is maintained.
/// </summary>
public bool IsMaintained { get; } public bool IsMaintained { get; }
/// <summary> /// <inheritdoc />
/// The message that should be displayed when the plugin is deprecated.
/// </summary>
public string? DeprecationMessage { get; } public string? DeprecationMessage { get; }
/// <summary> /// <summary>

View File

@ -0,0 +1,44 @@
namespace AIStudio.Tools.PluginSystem;
public sealed class PluginMetadata(PluginBase plugin) : IPluginMetadata
{
#region Implementation of IPluginMetadata
/// <inheritdoc />
public PluginType Type { get; } = plugin.Type;
/// <inheritdoc />
public Guid Id { get; } = plugin.Id;
/// <inheritdoc />
public string Name { get; } = plugin.Name;
/// <inheritdoc />
public string Description { get; } = plugin.Description;
/// <inheritdoc />
public PluginVersion Version { get; } = plugin.Version;
/// <inheritdoc />
public string[] Authors { get; } = plugin.Authors;
/// <inheritdoc />
public string SupportContact { get; } = plugin.SupportContact;
/// <inheritdoc />
public string SourceURL { get; } = plugin.SourceURL;
/// <inheritdoc />
public PluginCategory[] Categories { get; } = plugin.Categories;
/// <inheritdoc />
public PluginTargetGroup[] TargetGroups { get; } = plugin.TargetGroups;
/// <inheritdoc />
public bool IsMaintained { get; } = plugin.IsMaintained;
/// <inheritdoc />
public string? DeprecationMessage { get; } = plugin.DeprecationMessage;
#endregion
}