Exemplo n.º 1
0
        public void DoesntWrapSeekableStream()
        {
            var s = new TestStream(true, "some data");

            using (var actual = SeekableStreamWrapper.FromStream(s))
            {
                Assert.AreSame(s, actual);
                Assert.IsTrue(actual.CanSeek);
            }
        }
Exemplo n.º 2
0
        public void WrapsNonSeekableStream()
        {
            var s = new TestStream(false, "some data");

            using (var actual = SeekableStreamWrapper.FromStream(s))
            {
                Assert.AreNotSame(s, actual);
                Assert.IsInstanceOfType(typeof(SeekableStreamWrapper), actual);
                Assert.IsTrue(actual.CanSeek);
                Assert.IsFalse(actual.CanWrite);
            }
        }
Exemplo n.º 3
0
        public void WrapsNonSeekableStream()
        {
            var s = new TestStream(false, "some data");

            using (var actual = SeekableStreamWrapper.FromStream(s))
            {
                Assert.NotSame(s, actual);
                Assert.IsAssignableFrom(typeof(SeekableStreamWrapper), actual);
                Assert.True(actual.CanSeek);
                Assert.False(actual.CanWrite);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Allows .Build and .LoadImage to resize remote URLs
 /// </summary>
 /// <param name="source"></param>
 /// <param name="settings"></param>
 /// <param name="disposeStream"></param>
 /// <param name="path"></param>
 /// <param name="restoreStreamPosition"></param>
 /// <returns></returns>
 protected override Stream GetStream(object source, ResizeSettings settings, ref bool disposeStream, out string path, out bool restoreStreamPosition)
 {
     //Turn remote URLs into URI instances
     if (source is string && (((string)source).StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
                              ((string)source).StartsWith("https://", StringComparison.OrdinalIgnoreCase)))
     {
         if (Uri.IsWellFormedUriString((string)source, UriKind.Absolute))
         {
             source = new Uri((string)source);
         }
     }
     restoreStreamPosition = false;
     path = null;
     //Turn URI instances into streams
     if (source is Uri)
     {
         path = ((Uri)source).ToString();
         return(SeekableStreamWrapper.FromStream(GetUriStream((Uri)source), ref disposeStream));
     }
     return(null);
 }
Exemplo n.º 5
0
 public System.IO.Stream Open()
 {
     return(SeekableStreamWrapper.FromStream(parent.GetUriStream(new Uri(this.request.RemoteUrl))));
 }