mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds the plugins and metadata provider management API
This commit is contained in:
1 parent
6f501a51f3
commit
7d417c1710
51 files changed
+2294
No files matched your search
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="PluginEntity"/>.
|
||||
/// </summary>
|
||||
public static class PluginEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="pluginEntity"/> to <see cref="PluginResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static PluginResponse ToResponse(this PluginEntity pluginEntity)
|
||||
{
|
||||
return new PluginResponse(
|
||||
pluginEntity.Id,
|
||||
pluginEntity.Name,
|
||||
pluginEntity.Author,
|
||||
pluginEntity.Version,
|
||||
pluginEntity.Description,
|
||||
pluginEntity.LoadStatus,
|
||||
pluginEntity.LoadError,
|
||||
pluginEntity.ToSettings()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the settings of <paramref name="pluginEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginEntity">The repository entity whose settings are deserialized.</param>
|
||||
/// <returns>The deserialized settings, or <see langword="null"/> when no settings are stored.</returns>
|
||||
public static IReadOnlyDictionary<string, string>? ToSettings(this PluginEntity pluginEntity)
|
||||
{
|
||||
if (pluginEntity.SettingsJson is null)
|
||||
return null;
|
||||
return JsonSerializer.Deserialize<Dictionary<string, string>>(pluginEntity.SettingsJson);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user