/// <summary> /// Initializes a new instance of a RequestTask composing of the specified request Message and reponse Action /// </summary> /// <param name="request"></param> /// <param name="responseAction"></param> public RequestTask(Message request, Action<Message> responseAction) { if (request == null) throw new ArgumentNullException("Request Message"); if (responseAction == null) throw new ArgumentNullException("Response Action"); this.Request = request; this.ResponseAction = responseAction; }
/// <summary> /// Dispatches a response to the specified request Message with the given response action /// </summary> /// <param name="requestMessage"></param> /// <param name="respondAction"></param> public void Reply(Message requestMessage, Action<Message> respondAction) { var requestObject = messageFactory.ExtractRequest(requestMessage); var responseObject = requestDispatcher.Handle(requestObject); var responseMessage = CreateResponse(responseObject); respondAction(responseMessage); }