public TResult Dispatch <TParameter, TResult>(TParameter query)
            where TParameter : IQuery
            where TResult : IQueryResult
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            IQueryHandler <TParameter, TResult> handler = null;

            try
            {
                handler = _container.Resolve <IQueryHandler <TParameter, TResult> >();
                var results = handler.Retrieve(query);

                stopwatch.Stop();

                return(results);
            }
            catch (Exception ex)
            {
                stopwatch.Stop();
                throw;
            }
            finally
            {
                handler.Dispose();
            }
        }
Ejemplo n.º 2
0
        public async Task <TResult> Dispatch <TParameter, TResult>(TParameter query)
            where TParameter : class
        {
            IQueryHandler <TParameter, TResult> handler = provider.GetService(typeof(IQueryHandler <TParameter, TResult>)) as IQueryHandler <TParameter, TResult>;

            Log.Information(handler.GetType().ToString());

            return(await handler.Retrieve(query));
        }