Implement XAiMcpServer Stuffs ...

This commit is contained in:
2026-11-02 23:16:50 +03:30
parent 9e7710e345
commit 62aa8d51e6
31 changed files with 641 additions and 7 deletions
@@ -0,0 +1,79 @@
using System.Linq;
using xModels.Dtos;
using System.Threading;
using xCommons.Extensions;
using xAiModels.Models.Dtos;
using System.Threading.Tasks;
using xAiModels.Models.Entities;
using System.Collections.Generic;
using xIdentityService.Interfaces;
using xAiModels.Interfaces.Enrichers;
namespace xAiModels.Providers.Enrichers
{
public class XAiMcpServerEnricher : IXAiMcpServerEnricher
{
private readonly IXPersonService personService;
public XAiMcpServerEnricher(
IXPersonService personService
)
{
this.personService = personService;
}
public virtual async Task<XAiMcpServerDto> Enrich(
XAiMcpServer source,
CancellationToken cancellationToken = default
)
{
//
var result = source.MapConvert<XAiMcpServerDto, XAiMcpServer>();
result = await Enrich(
source: result,
cancellationToken: cancellationToken
);
//
return result;
}
public virtual async Task<XAiMcpServerDto> Enrich(
XAiMcpServerDto source,
CancellationToken cancellationToken = default
)
{
//
XPersonDto owner = null;
if (!source.OwnerId.IsNullOrEmpty())
{
owner = await personService.GetPerson(source.OwnerId);
}
//
var result = source.MapConvert<XAiMcpServerDto, XAiMcpServerDto>();
result.Owner = owner;
//
return result;
}
public virtual async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
IEnumerable<XAiMcpServer> sources,
CancellationToken cancellationToken = default
)
{
var tasks = sources.Select(x => Enrich(x, cancellationToken));
return await Task.WhenAll(tasks);
}
public virtual async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
IEnumerable<XAiMcpServerDto> sources,
CancellationToken cancellationToken = default
)
{
var tasks = sources.Select(x => Enrich(x, cancellationToken));
return await Task.WhenAll(tasks);
}
}
}