Ejemplo n.º 1
0
        public async Task <Response <TResponseData> > RequestAsync <TResponseData>(IAsyncRequest <TResponseData> query)
        {
            Response <TResponseData> response = new Response <TResponseData>();

            try
            {
                var plan         = new MediatorPlan <TResponseData>(typeof(IAsyncRequestHandler <,>), "HandleAsync", query.GetType(), _dependencyResolver);
                var interceptors = GetRequestInterceptors(plan);

                foreach (var requestInterceptor in interceptors)
                {
                    await requestInterceptor.BeforeInvokeAsync(plan.HandleMethod, query, query.GetType());
                }

                response.Data = await plan.InvokeAsync((object)query);

                foreach (var requestInterceptor in interceptors)
                {
                    await requestInterceptor.AfterInvokeAsync(plan.HandleMethod, query, query.GetType(), response.Data);
                }
            }
            catch (Exception ex)
            {
                response.Exception = ex;
            }
            return(response);
        }
Ejemplo n.º 2
0
        public async Task <Response <TResponseData> > RequestAsync <TResponseData>(IAsyncRequest <TResponseData> query)
        {
            var response = new Response <TResponseData>();

            try
            {
                var plan = new MediatorPlan <TResponseData>(typeof(IAsyncRequestHandler <,>), "HandleAsync", query.GetType(), _dependencyResolver);

                response.Data = await plan.InvokeAsync(query);
            }
            catch (Exception e)
            {
                response.Exception = e;
            }

            return(response);
        }
Ejemplo n.º 3
0
        public Task <TResponseData> RequestAsync <TResponseData>(IAsyncRequest <TResponseData> query)
        {
            var plan = new MediatorPlan <TResponseData>(typeof(IAsyncRequestHandler <,>), "HandleAsync", query.GetType(), _container);

            return(plan.InvokeAsync(query));
        }
Ejemplo n.º 4
0
        public async Task <TResponse> SendAsync <TResponse>(ICommand <TResponse> query)
        {
            var plan = new MediatorPlan <TResponse>(typeof(ICommandHandler <,>), "SendAsync", query.GetType(), _componentContext);

            return(await plan.InvokeAsync(query));
        }