dotnet-cqrs/PoweredSoft.CQRS.DynamicQuery/DynamicQueryHandler.cs

42 lines
1.8 KiB
C#
Raw Normal View History

2021-02-02 19:01:29 -05:00
using PoweredSoft.CQRS.DynamicQuery.Abstractions;
using PoweredSoft.DynamicQuery.Core;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace PoweredSoft.CQRS.DynamicQuery
{
2021-02-02 19:32:39 -05:00
public class DynamicQueryHandler<TSource, TDestination>
: DynamicQueryHandlerBase<TSource, TDestination>,
2021-02-02 19:01:29 -05:00
PoweredSoft.CQRS.Abstractions.IQueryHandler<IDynamicQuery<TSource, TDestination>, IQueryExecutionResult<TDestination>>
where TSource : class
where TDestination : class
{
2021-02-02 19:32:39 -05:00
public DynamicQueryHandler(IQueryHandlerAsync queryHandlerAsync, IEnumerable<IQueryableProvider<TSource>> queryableProviders) : base(queryHandlerAsync, queryableProviders)
2021-02-02 19:01:29 -05:00
{
}
2021-02-02 19:32:39 -05:00
public Task<IQueryExecutionResult<TDestination>> HandleAsync(IDynamicQuery<TSource, TDestination> query, CancellationToken cancellationToken = default)
2021-02-02 19:01:29 -05:00
{
2021-02-02 19:32:39 -05:00
return ProcessQueryAsync(query, cancellationToken);
2021-02-02 19:01:29 -05:00
}
2021-02-02 19:32:39 -05:00
}
2021-02-02 19:01:29 -05:00
2021-02-02 19:32:39 -05:00
public class DynamicQueryHandler<TSource, TDestination, TParams>
: DynamicQueryHandlerBase<TSource, TDestination>,
PoweredSoft.CQRS.Abstractions.IQueryHandler<IDynamicQuery<TSource, TDestination, TParams>, IQueryExecutionResult<TDestination>>
where TSource : class
where TDestination : class
where TParams : class
{
public DynamicQueryHandler(IQueryHandlerAsync queryHandlerAsync, IEnumerable<IQueryableProvider<TSource>> queryableProviders) : base(queryHandlerAsync, queryableProviders)
2021-02-02 19:01:29 -05:00
{
}
2021-02-02 19:32:39 -05:00
public Task<IQueryExecutionResult<TDestination>> HandleAsync(IDynamicQuery<TSource, TDestination, TParams> query, CancellationToken cancellationToken = default)
2021-02-02 19:01:29 -05:00
{
2021-02-02 19:32:39 -05:00
return this.ProcessQueryAsync(query, cancellationToken);
2021-02-02 19:01:29 -05:00
}
}
}