aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/NonClosingStreamWrapper.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/WixToolset.Data/NonClosingStreamWrapper.cs84
1 files changed, 0 insertions, 84 deletions
diff --git a/src/WixToolset.Data/NonClosingStreamWrapper.cs b/src/WixToolset.Data/NonClosingStreamWrapper.cs
deleted file mode 100644
index a2d3be6a..00000000
--- a/src/WixToolset.Data/NonClosingStreamWrapper.cs
+++ /dev/null
@@ -1,84 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Data
4{
5 using System;
6 using System.IO;
7
8 /// <summary>
9 /// Wrapper around stream to prevent other streams (like BinaryReader/Writer) from prematurely
10 /// closing a parent stream.
11 /// </summary>
12 internal class NonClosingStreamWrapper : Stream
13 {
14 private Stream stream;
15
16 public NonClosingStreamWrapper(Stream stream)
17 {
18 this.stream = stream;
19 }
20
21 public override bool CanRead => this.stream.CanRead;
22
23 public override bool CanSeek => this.stream.CanSeek;
24
25 public override bool CanTimeout => this.stream.CanTimeout;
26
27 public override bool CanWrite => this.stream.CanWrite;
28
29 public override long Length => this.stream.Length;
30
31 public override long Position
32 {
33 get => this.stream.Position;
34 set => this.stream.Position = value;
35 }
36
37 public override int ReadTimeout
38 {
39 get => this.stream.ReadTimeout;
40 set => this.stream.ReadTimeout = value;
41 }
42
43 public override int WriteTimeout
44 {
45 get => this.stream.WriteTimeout;
46 set => this.stream.WriteTimeout = value;
47 }
48
49 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => this.stream.BeginRead(buffer, offset, count, callback, state);
50
51 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => this.stream.BeginWrite(buffer, offset, count, callback, state);
52
53 public override int EndRead(IAsyncResult asyncResult) => this.stream.EndRead(asyncResult);
54
55 public override void EndWrite(IAsyncResult asyncResult) => this.stream.EndWrite(asyncResult);
56
57 public override void Flush() => this.stream.Flush();
58
59 public override int Read(byte[] buffer, int offset, int count) => this.stream.Read(buffer, offset, count);
60
61 public override int ReadByte() => this.stream.ReadByte();
62
63 public override long Seek(long offset, SeekOrigin origin) => this.stream.Seek(offset, origin);
64
65 public override void SetLength(long value) => this.stream.SetLength(value);
66
67 public override void Write(byte[] buffer, int offset, int count) => this.stream.Write(buffer, offset, count);
68
69 public override void WriteByte(byte value) => this.stream.WriteByte(value);
70
71 public override void Close()
72 {
73 // Do not pass through the call since this is what we are overriding.
74 }
75
76 protected override void Dispose(bool disposing)
77 {
78 if (disposing)
79 {
80 this.stream.Flush();
81 }
82 }
83 }
84}