Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (23 sloc) 728 Bytes
using System;
using System.Threading.Tasks;
using Autofac;
using DShop.Common.Handlers;
using DShop.Common.Types;
namespace DShop.Common.Dispatchers
{
public class QueryDispatcher : IQueryDispatcher
{
private readonly IComponentContext _context;
public QueryDispatcher(IComponentContext context)
{
_context = context;
}
public async Task<TResult> QueryAsync<TResult>(IQuery<TResult> query)
{
var handlerType = typeof(IQueryHandler<,>)
.MakeGenericType(query.GetType(), typeof(TResult));
dynamic handler = _context.Resolve(handlerType);
return await handler.HandleAsync((dynamic)query);
}
}
}