23 lines
883 B
C#
23 lines
883 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using OpenHarbor.CQRS.Abstractions.Discovery;
|
|||
|
|
|||
|
namespace OpenHarbor.CQRS.Discovery;
|
|||
|
|
|||
|
public sealed class CommandDiscovery : ICommandDiscovery
|
|||
|
{
|
|||
|
private readonly IEnumerable<ICommandMeta> _commandMetas;
|
|||
|
|
|||
|
public CommandDiscovery(IEnumerable<ICommandMeta> commandMetas)
|
|||
|
{
|
|||
|
_commandMetas = commandMetas;
|
|||
|
}
|
|||
|
|
|||
|
public IEnumerable<ICommandMeta> GetCommands() => _commandMetas;
|
|||
|
public ICommandMeta FindCommand(string name) => _commandMetas.FirstOrDefault(t => t.Name == name);
|
|||
|
public ICommandMeta FindCommand(Type commandType) => _commandMetas.FirstOrDefault(t => t.CommandType == commandType);
|
|||
|
public bool CommandExists(string name) => _commandMetas.Any(t => t.Name == name);
|
|||
|
public bool CommandExists(Type commandType) => _commandMetas.Any(t => t.CommandType == commandType);
|
|||
|
}
|