dotnet-cqrs/OpenHarbor.CQRS/Discovery/QueryDiscovery.cs
Mathias Beaulieu-Duncan 1c81288895 update namespaces
refactor the name of the organisation
2023-11-04 15:24:56 -04:00

24 lines
829 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using OpenHarbor.CQRS.Abstractions.Discovery;
namespace OpenHarbor.CQRS.Discovery;
public sealed class QueryDiscovery : IQueryDiscovery
{
private readonly IEnumerable<IQueryMeta> _queryMetas;
public QueryDiscovery(IEnumerable<IQueryMeta> queryMetas)
{
_queryMetas = queryMetas;
}
public IEnumerable<IQueryMeta> GetQueries() => _queryMetas;
public IQueryMeta FindQuery(string name) => _queryMetas.FirstOrDefault(t => t.Name == name);
public IQueryMeta FindQuery(Type queryType) => _queryMetas.FirstOrDefault(t => t.QueryType == queryType);
public bool QueryExists(string name) => _queryMetas.Any(t => t.Name == name);
public bool QueryExists(Type queryType) => _queryMetas.Any(t => t.QueryType == queryType);
}