public void DoesntWrapSeekableStream() { var s = new TestStream(true, "some data"); using (var actual = SeekableStreamWrapper.FromStream(s)) { Assert.AreSame(s, actual); Assert.IsTrue(actual.CanSeek); } }
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); } }
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); } }
/// <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); }
public System.IO.Stream Open() { return(SeekableStreamWrapper.FromStream(parent.GetUriStream(new Uri(this.request.RemoteUrl)))); }