BotSharp/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentUtilityMongoElement.cs

44 lines
1.5 KiB
C#
Raw Normal View History

2024-11-20 23:10:38 +00:00
using BotSharp.Abstraction.Agents.Models;
namespace BotSharp.Plugin.MongoStorage.Models;
2025-02-08 21:49:26 +00:00
[BsonIgnoreExtraElements(Inherited = true)]
2024-11-20 23:10:38 +00:00
public class AgentUtilityMongoElement
{
public string Name { get; set; } = default!;
2024-11-21 05:46:09 +00:00
public bool Disabled { get; set; }
2024-11-20 23:10:38 +00:00
public List<UtilityFunctionMongoElement> Functions { get; set; } = [];
public List<UtilityTemplateMongoElement> Templates { get; set; } = [];
public static AgentUtilityMongoElement ToMongoElement(AgentUtility utility)
{
return new AgentUtilityMongoElement
{
Name = utility.Name,
2024-11-21 05:46:09 +00:00
Disabled = utility.Disabled,
2024-11-20 23:10:38 +00:00
Functions = utility.Functions?.Select(x => new UtilityFunctionMongoElement(x.Name))?.ToList() ?? [],
Templates = utility.Templates?.Select(x => new UtilityTemplateMongoElement(x.Name))?.ToList() ?? []
};
}
public static AgentUtility ToDomainElement(AgentUtilityMongoElement utility)
{
return new AgentUtility
{
Name = utility.Name,
2024-11-21 05:46:09 +00:00
Disabled = utility.Disabled,
2024-11-20 23:10:38 +00:00
Functions = utility.Functions?.Select(x => new UtilityFunction(x.Name))?.ToList() ?? [],
Templates = utility.Templates?.Select(x => new UtilityTemplate(x.Name))?.ToList() ?? []
};
}
}
public class UtilityFunctionMongoElement(string name)
2024-11-20 23:10:38 +00:00
{
public string Name { get; set; } = name;
2024-11-20 23:10:38 +00:00
}
public class UtilityTemplateMongoElement(string name)
2024-11-20 23:10:38 +00:00
{
public string Name { get; set; } = name;
2024-11-20 23:10:38 +00:00
}