internal ReadOnlyIStorage(IStorage storage, ReadOnlyILockBytes lockBytesStream) { if (storage == null) { throw new ArgumentNullException("storage"); } _storage = storage; _readOnlyILockBytes = lockBytesStream; }
internal static IStorage OpenStorage(Stream stream) { IStorage storage = null; uint grfMode = (uint)(STGM.READ | STGM.SHARE_EXCLUSIVE); ReadOnlyILockBytes readOnlyLockBytes = new ReadOnlyILockBytes(stream); Marshal.ThrowExceptionForHR(NativeMethods.StgOpenStorageOnILockBytes(readOnlyLockBytes, null, grfMode, IntPtr.Zero, 0, out storage)); return(new ReadOnlyIStorage(storage, readOnlyLockBytes)); }
protected virtual void Dispose(bool disposing) { try { if (disposing && (_storage != null)) { Marshal.FinalReleaseComObject(_storage); if (_readOnlyILockBytes != null) { _readOnlyILockBytes.Dispose(); } } } finally { _storage = null; _readOnlyILockBytes = null; } }