當前位置: 首頁>>代碼示例>>C#>>正文


C# Response.Contents方法代碼示例

本文整理匯總了C#中Nancy.Response.Contents方法的典型用法代碼示例。如果您正苦於以下問題:C# Response.Contents方法的具體用法?C# Response.Contents怎麽用?C# Response.Contents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nancy.Response的用法示例。


在下文中一共展示了Response.Contents方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadResponseContent

        private string ReadResponseContent(Response response)
        {
            string content;
            using (var stream = new MemoryStream())
            {
                response.Contents(stream);
                stream.Position = 0;
                using (var reader = new StreamReader(stream))
                {
                    content = reader.ReadToEnd();
                }
            }

            return content;
        }
開發者ID:humblelistener,項目名稱:pact-net,代碼行數:15,代碼來源:MockProviderAdminRequestHandlerTests.cs

示例2: ResponseSummary

            public ResponseSummary(Response response)
            {
                _contentType = response.ContentType;
                _headers = response.Headers;
                _statusCode = response.StatusCode;

                using (var memoryStream = new MemoryStream())
                {
                    response.Contents(memoryStream);
                    _contents = memoryStream.ToArray();
                }
            }
開發者ID:pomma89,項目名稱:KVLite,代碼行數:12,代碼來源:CachingBootstrapper.cs

示例3: SendNancyResponseToResult

        static void SendNancyResponseToResult(Response response, ResultDelegate result)
        {
            if (!response.Headers.ContainsKey("Content-Type") && !string.IsNullOrWhiteSpace(response.ContentType))
                response.Headers["Content-Type"] = response.ContentType;

            result(
                string.Format("{0:000} UNK", (int) response.StatusCode),
                response.Headers,
                (next, error, complete) =>
                {
                    using (var stream = new OutputStream(next, complete))
                    {
                        try
                        {
                            response.Contents(stream);
                        }
                        catch (Exception ex)
                        {
                            error(ex);
                        }
                    }
                    return () => { };
                });
        }
開發者ID:loudej,項目名稱:gato,代碼行數:24,代碼來源:Application.cs

示例4: MapNancyResponse

 private HttpResponseMessage MapNancyResponse(Response src)
 {
     var dst = new HttpResponseMessage((HttpStatusCode)src.StatusCode);
     if (src.Contents != null)
     {
         using (var memStream = new MemoryStream())
         {
             src.Contents(memStream);
             dst.Content = new ByteArrayContent(memStream.ToArray());
         }
         foreach (var header in src.Headers)
         {
             if (contentHeaders.Contains(header.Key))
                 dst.Content.Headers.Add(header.Key, header.Value);
         }
         if (src.ContentType != null)
             dst.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(src.ContentType);
     }
     foreach (var header in src.Headers.Where(x => !contentHeaders.Contains(x.Key)))
         dst.Headers.Add(header.Key, header.Value);
     return dst;
 }
開發者ID:Pomona,項目名稱:Pomona,代碼行數:22,代碼來源:NancyTestingHttpMessageHandler.cs


注:本文中的Nancy.Response.Contents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。