/// <summary> /// Converts the segment of the memory-mapped file /// </summary> /// <remarks> /// The caller is responsible for disposing of the returned stream. /// </remarks> /// <value>The stream representing virtual memory of the memory-mapped file.</value> public Stream AsStream() { if (accessor is null) { return(Stream.Null); } FileAccess access; switch (accessor.CanRead.ToInt32() + (accessor.CanWrite.ToInt32() << 1)) { default: access = default; break; case 1: access = FileAccess.Read; break; case 2: access = FileAccess.Write; break; case 3: access = FileAccess.ReadWrite; break; } return(Pointer.AsStream(Size, access)); }
/// <summary> /// Converts the segment of the memory-mapped file. /// </summary> /// <remarks> /// The caller is responsible for disposing of the returned stream. /// </remarks> /// <returns>The stream representing virtual memory of the memory-mapped file.</returns> public Stream AsStream() => accessor is null ? Stream.Null : Pointer.AsStream(Size, accessor.GetFileAccess());