You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System.Collections.Immutable;
|
|
|
|
|
using Connected;
|
|
|
|
|
using Connected.Entities;
|
|
|
|
|
using Connected.Net.Endpoints;
|
|
|
|
|
using Connected.ServiceModel;
|
|
|
|
|
using Connected.Services;
|
|
|
|
|
|
|
|
|
|
namespace Common.Net;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Endpoints are singleton but their service is scoped so we must use Isolated database connections for all methods.
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal sealed class QueryEndpoints : ServiceFunction<IDto, ImmutableList<IEndpoint>?>
|
|
|
|
|
{
|
|
|
|
|
public QueryEndpoints(IEndpointCache cache)
|
|
|
|
|
{
|
|
|
|
|
Cache = cache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEndpointCache Cache { get; }
|
|
|
|
|
|
|
|
|
|
protected override async Task<ImmutableList<IEndpoint>?> OnInvoke()
|
|
|
|
|
{
|
|
|
|
|
return await (from dc in Cache
|
|
|
|
|
select dc).AsEntities<IEndpoint>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
internal sealed class SelectEndpoint : ServiceFunction<PrimaryKeyArgs<int>, IEndpoint?>
|
|
|
|
|
{
|
|
|
|
|
public SelectEndpoint(IEndpointCache cache)
|
|
|
|
|
{
|
|
|
|
|
Cache = cache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEndpointCache Cache { get; }
|
|
|
|
|
|
|
|
|
|
protected override async Task<IEndpoint?> OnInvoke()
|
|
|
|
|
{
|
|
|
|
|
return await (from dc in Cache
|
|
|
|
|
where dc.Id == Arguments.Id
|
|
|
|
|
select dc).AsEntity();
|
|
|
|
|
}
|
|
|
|
|
}
|