Пример #1
0
        public static HttpRequestMessageWrapperEx ToTransportRequest(this AppRequestMessage request)
        {
            // Could interact with the wrapper directly, but trying to use
            // http message as much as possible so that if we want to push
            // the wrapper contents into an http message, would prob have better result.
            var http = new HttpRequestMessage();

            http.Content = new StringContent(JsonConvert.SerializeObject(request));

            http.Headers.Add(RequestIdHeader, request.Headers.MessageId);
            http.Headers.Date = request.Headers.CreatedOn;
            //http.Headers.Add(RequestDateHeader, request.Headers.CreatedOn?.ToString());
            http.Headers.Add(RequestChannelHeader, request.Headers.SourceChannel);

            var content = http.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
            var wrapper = new HttpRequestMessageWrapperEx(http, content);

            return(wrapper);
        }
Пример #2
0
 public static TRequest ToAppRequestMessage <TRequest>(this HttpRequestMessageWrapperEx wrapper) where TRequest : AppRequestMessage
 {
     return(JsonConvert.DeserializeObject <TRequest>(wrapper.Content));
 }
Пример #3
0
 public HttpResponseMessageWrapperEx(HttpResponseMessage httpResponse, string content, HttpRequestMessageWrapperEx requestWrapper) : base(httpResponse, content)
 {
     this.RequestWrapper = requestWrapper;
 }