public Response <TResponseData> Send <TResponseData>(ICommand <TResponseData> command) { var response = new Response <TResponseData>(); var postProcessors = _container.GetAllInstances <ICommandPostHandleInspector>(); try { var plan = new MediatorPlan <TResponseData>(typeof(ICommandHandler <,>), "Handle", command.GetType(), _container); response.Data = plan.Invoke(command); } catch (Exception e) { response.Exception = e; } foreach (var commandPostHandleInspector in postProcessors) { if (commandPostHandleInspector.InterestedIn(command)) { commandPostHandleInspector.Inspect(command); } } return(response); }
public virtual Response <TResponseData> Request <TResponseData>(IRequest <TResponseData> request) { Response <TResponseData> response = new Response <TResponseData>(); try { var plan = new MediatorPlan <TResponseData>(typeof(IRequestHandler <,>), "Handle", request.GetType(), _dependencyResolver); List <RequestInterceptor> requestInterceptors = GetRequestInterceptors(plan); foreach (RequestInterceptor requestInterceptor in requestInterceptors) { requestInterceptor.BeforeInvoke(plan.HandleMethod, request, request.GetType()); } response.Data = plan.Invoke(request); foreach (RequestInterceptor requestInterceptor in requestInterceptors) { requestInterceptor.AfterInvoke(plan.HandleMethod, request, request.GetType(), response.Data); } } catch (Exception ex) { response.Exception = ex; } return(response); }
public virtual Response <TResponseData> Request <TResponseData>(IQuery <TResponseData> query) { var response = new Response <TResponseData>(); try { var plan = new MediatorPlan <TResponseData>(typeof(IQueryHandler <,>), "Handle", query.GetType(), _container); response.Data = plan.Invoke(query); } catch (Exception e) { response.Exception = e; } return(response); }
public virtual Response <TResponseData> Request <TResponseData>(IRequest <TResponseData> request) { var response = new Response <TResponseData>(); try { var plan = new MediatorPlan <TResponseData>(typeof(IRequestHandler <,>), "Handle", request.GetType(), _dependencyResolver); response.Data = plan.Invoke(request); } catch (Exception e) { response.Exception = e; } return(response); }