diff options
Diffstat (limited to '')
-rw-r--r-- | src/WixToolset.Data/NonClosingStreamWrapper.cs | 91 |
1 files changed, 35 insertions, 56 deletions
diff --git a/src/WixToolset.Data/NonClosingStreamWrapper.cs b/src/WixToolset.Data/NonClosingStreamWrapper.cs index 53d17d4d..a2d3be6a 100644 --- a/src/WixToolset.Data/NonClosingStreamWrapper.cs +++ b/src/WixToolset.Data/NonClosingStreamWrapper.cs | |||
@@ -18,88 +18,67 @@ namespace WixToolset.Data | |||
18 | this.stream = stream; | 18 | this.stream = stream; |
19 | } | 19 | } |
20 | 20 | ||
21 | public override bool CanRead { get { return this.stream.CanRead; } } | 21 | public override bool CanRead => this.stream.CanRead; |
22 | 22 | ||
23 | public override bool CanSeek { get { return this.stream.CanSeek; } } | 23 | public override bool CanSeek => this.stream.CanSeek; |
24 | 24 | ||
25 | public override bool CanTimeout { get { return this.stream.CanTimeout; } } | 25 | public override bool CanTimeout => this.stream.CanTimeout; |
26 | 26 | ||
27 | public override bool CanWrite { get { return this.stream.CanWrite; } } | 27 | public override bool CanWrite => this.stream.CanWrite; |
28 | 28 | ||
29 | public override long Length { get { return this.stream.Length; } } | 29 | public override long Length => this.stream.Length; |
30 | 30 | ||
31 | public override long Position { get { return this.stream.Position; } set { this.stream.Position = value; } } | 31 | public override long Position |
32 | |||
33 | public override int ReadTimeout { get { return this.stream.ReadTimeout; } set { this.stream.ReadTimeout = value; } } | ||
34 | |||
35 | public override int WriteTimeout { get { return this.stream.WriteTimeout; } set { this.stream.WriteTimeout = value; } } | ||
36 | |||
37 | public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) | ||
38 | { | 32 | { |
39 | return this.stream.BeginRead(buffer, offset, count, callback, state); | 33 | get => this.stream.Position; |
34 | set => this.stream.Position = value; | ||
40 | } | 35 | } |
41 | 36 | ||
42 | public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) | 37 | public override int ReadTimeout |
43 | { | 38 | { |
44 | return this.stream.BeginWrite(buffer, offset, count, callback, state); | 39 | get => this.stream.ReadTimeout; |
40 | set => this.stream.ReadTimeout = value; | ||
45 | } | 41 | } |
46 | 42 | ||
47 | public override void Close() | 43 | public override int WriteTimeout |
48 | { | 44 | { |
49 | // Do not pass through the call since this is what we are overriding. | 45 | get => this.stream.WriteTimeout; |
46 | set => this.stream.WriteTimeout = value; | ||
50 | } | 47 | } |
51 | 48 | ||
52 | protected override void Dispose(bool disposing) | 49 | public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => this.stream.BeginRead(buffer, offset, count, callback, state); |
53 | { | ||
54 | if (disposing) | ||
55 | { | ||
56 | this.stream.Flush(); | ||
57 | } | ||
58 | } | ||
59 | 50 | ||
60 | public override int EndRead(IAsyncResult asyncResult) | 51 | public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => this.stream.BeginWrite(buffer, offset, count, callback, state); |
61 | { | ||
62 | return this.stream.EndRead(asyncResult); | ||
63 | } | ||
64 | 52 | ||
65 | public override void EndWrite(IAsyncResult asyncResult) | 53 | public override int EndRead(IAsyncResult asyncResult) => this.stream.EndRead(asyncResult); |
66 | { | ||
67 | this.stream.EndWrite(asyncResult); | ||
68 | } | ||
69 | 54 | ||
70 | public override void Flush() | 55 | public override void EndWrite(IAsyncResult asyncResult) => this.stream.EndWrite(asyncResult); |
71 | { | ||
72 | this.stream.Flush(); | ||
73 | } | ||
74 | 56 | ||
75 | public override int Read(byte[] buffer, int offset, int count) | 57 | public override void Flush() => this.stream.Flush(); |
76 | { | ||
77 | return this.stream.Read(buffer, offset, count); | ||
78 | } | ||
79 | 58 | ||
80 | public override int ReadByte() | 59 | public override int Read(byte[] buffer, int offset, int count) => this.stream.Read(buffer, offset, count); |
81 | { | ||
82 | return this.stream.ReadByte(); | ||
83 | } | ||
84 | 60 | ||
85 | public override long Seek(long offset, SeekOrigin origin) | 61 | public override int ReadByte() => this.stream.ReadByte(); |
86 | { | ||
87 | return this.stream.Seek(offset, origin); | ||
88 | } | ||
89 | 62 | ||
90 | public override void SetLength(long value) | 63 | public override long Seek(long offset, SeekOrigin origin) => this.stream.Seek(offset, origin); |
91 | { | 64 | |
92 | this.stream.SetLength(value); | 65 | public override void SetLength(long value) => this.stream.SetLength(value); |
93 | } | ||
94 | 66 | ||
95 | public override void Write(byte[] buffer, int offset, int count) | 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() | ||
96 | { | 72 | { |
97 | this.stream.Write(buffer, offset, count); | 73 | // Do not pass through the call since this is what we are overriding. |
98 | } | 74 | } |
99 | 75 | ||
100 | public override void WriteByte(byte value) | 76 | protected override void Dispose(bool disposing) |
101 | { | 77 | { |
102 | this.stream.WriteByte(value); | 78 | if (disposing) |
79 | { | ||
80 | this.stream.Flush(); | ||
81 | } | ||
103 | } | 82 | } |
104 | } | 83 | } |
105 | } | 84 | } |