Exemplo n.º 1
0
        /// <summary>
        /// Fetches an image from the web site passed across.
        /// </summary>
        /// <param name="webSite"></param>
        /// <param name="webPathAndFileName"></param>
        /// <returns></returns>
        private Image FetchFromWebSite(IWebSite webSite, string webPathAndFileName)
        {
            Image result = null;

            var simpleContent = webSite.RequestSimpleContent(webPathAndFileName);

            if (simpleContent != null && simpleContent.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                using (var memoryStream = new MemoryStream(simpleContent.Content)) {
                    using (var image = Image.FromStream(memoryStream)) {
                        result = new Bitmap(image);     // work around the problem that GDI+ has with images built from streams being accessed after the stream has been disposed
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 public void WebSite_RequestSimpleContent_Throws_If_Passed_Null()
 {
     _WebSite.AttachSiteToServer(_WebServer.Object);
     _WebSite.RequestSimpleContent(null);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Fetches an image from the web site passed across.
 /// </summary>
 /// <param name="webSite"></param>
 /// <param name="webPathAndFileName"></param>
 /// <returns></returns>
 private Image FetchFromWebSite(IWebSite webSite, string webPathAndFileName)
 {
     return(ExtractFromSimpleContent(webSite.RequestSimpleContent(webPathAndFileName)));
 }