You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: System.IO.Streams/MemoryStream.cs
+35-8Lines changed: 35 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,8 @@ public class MemoryStream : Stream
27
27
privatereadonlybool_expandable;
28
28
// Is this stream open or closed?
29
29
privatebool_isOpen;
30
+
// Is the stream writable
31
+
privatebool_isWritable;
30
32
31
33
privateconstintMemStreamMaxLength=0xFFFF;
32
34
@@ -50,6 +52,7 @@ public MemoryStream()
50
52
// Must be 0 for byte[]'s created by MemoryStream
51
53
_origin=0;
52
54
_isOpen=true;
55
+
_isWritable=true;
53
56
}
54
57
55
58
/// <summary>
@@ -61,18 +64,24 @@ public MemoryStream()
61
64
/// <para>
62
65
/// The <see cref="CanRead"/>, <see cref="CanSeek"/>, and <see cref="CanWrite"/> properties are all set to <see langword="true"/>.
63
66
/// </para>
64
-
/// <para>
65
-
/// The capacity of the current stream automatically increases when you use the <see cref="SetLength"/> method to set the length to a value larger than the capacity of the current stream.
/// Initializes a new non-resizable instance of the <see cref="MemoryStream"/> class based on the specified byte array with the <see cref="CanWrite"/> property set as specified.
72
+
/// </summary>
73
+
/// <param name="buffer">The array of unsigned bytes from which to create the current stream.</param>
74
+
/// <param name="isWritable">A bool indicating whether the stream should be writable</param>
75
+
/// <exception cref="ArgumentNullException"><paramref name="buffer"/> is <see langword="null"/>.</exception>
76
+
publicMemoryStream(byte[]buffer,boolisWritable)
69
77
{
70
78
_buffer=buffer??thrownewArgumentNullException();
71
79
72
80
_length=_capacity=buffer.Length;
73
81
_expandable=false;
74
82
_origin=0;
75
83
_isOpen=true;
84
+
_isWritable=isWritable;
76
85
}
77
86
78
87
/// <summary>
@@ -115,7 +124,7 @@ public MemoryStream(byte[] buffer)
115
124
/// If the stream is closed, this property returns <see langword="false"/>.
0 commit comments