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); }
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); }
public Task <TResponseData> RequestAsync <TResponseData>(IAsyncRequest <TResponseData> query) { var plan = new MediatorPlan <TResponseData>(typeof(IAsyncRequestHandler <,>), "HandleAsync", query.GetType(), _container); return(plan.InvokeAsync(query)); }
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)); }