public static IStream FromStream(Stream stream, StreamInfo streamInfo) { if (stream == null) throw new ArgumentNullException("stream"); return new StreamWrapper(stream, streamInfo); }
public static IStream FromFile(string fileName, FileMode mode, StreamInfo streamInfo) { if (fileName == null) throw new ArgumentNullException("fileName"); return FromStream(File.Open(fileName, mode), streamInfo ?? StreamInfo.FromFile(fileName)); }
public static IStream FromByteArray(byte[] byteArray, StreamInfo streamInfo) { if (byteArray == null) throw new ArgumentNullException("byteArray"); return FromStream(new MemoryStream(byteArray), streamInfo); }
public static IStream FromManifestResourceStream(Assembly assembly, string resourceName, StreamInfo streamInfo) { if (assembly == null) throw new ArgumentNullException("assembly"); if (resourceName == null) throw new ArgumentNullException("resourceName"); var stream = assembly.GetManifestResourceStream(resourceName); if (stream == null) throw new IOException(String.Format(NeutralResources.ResourceNotFound, resourceName, assembly.FullName)); if (streamInfo == null) { streamInfo = new StreamInfo { Name = resourceName }; } return FromStream(stream, streamInfo); }
public StreamWrapper(Stream stream, StreamInfo streamInfo) { _stream = stream; if (streamInfo != null) { Name = streamInfo.Name; DisplayName = streamInfo.DisplayName; CreationTime = streamInfo.CreationTime; LastWriteTime = streamInfo.LastWriteTime; } if (_stream.CanRead) State |= StreamState.Readable; if (_stream.CanWrite) State |= StreamState.Writable; if (_stream.CanSeek) State |= StreamState.Seekable; }