// ReSharper disable UnusedMember.Local internal void ServiceRequestResponseMethodGeneric <TRequest, TResponse>( MethodInfo concreteMethodInfo, RequestResponseOperationAttribute requestResponseAttribute) // ReSharper restore UnusedMember.Local { var requestEndpointDetails = _endpointDetailsProvider .GetEndpointDetails(requestResponseAttribute.RequestEndpointKey); var responseEndpointDetails = _endpointDetailsProvider .GetEndpointDetails(requestResponseAttribute.ResponseEndpointKey); var execute = (Func <TRequest, TResponse>)Delegate.CreateDelegate( typeof(Func <TRequest, TResponse>), this, concreteMethodInfo, true); var subscription = _requestResponder .GetRespondableRequestStream <TRequest, TResponse>( requestEndpointDetails, responseEndpointDetails) .Subscribe(respondableRequest => { RequestContext.Current = new RequestContext(respondableRequest.SenderSessionId); try { var response = execute(respondableRequest.Request); respondableRequest.Respond(response); } catch (Exception error) { respondableRequest.Respond(error); } finally { RequestContext.Current = null; } }); _subscriptions.Add(subscription); }