aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/CodedOutputStream.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf/CodedOutputStream.cs')
-rw-r--r--csharp/src/Google.Protobuf/CodedOutputStream.cs42
1 files changed, 16 insertions, 26 deletions
diff --git a/csharp/src/Google.Protobuf/CodedOutputStream.cs b/csharp/src/Google.Protobuf/CodedOutputStream.cs
index b91d6d70..b084c14f 100644
--- a/csharp/src/Google.Protobuf/CodedOutputStream.cs
+++ b/csharp/src/Google.Protobuf/CodedOutputStream.cs
@@ -65,7 +65,20 @@ namespace Google.Protobuf
private readonly Stream output;
#region Construction
+ /// <summary>
+ /// Creates a new CodedOutputStream that writes directly to the given
+ /// byte array. If more bytes are written than fit in the array,
+ /// OutOfSpaceException will be thrown.
+ /// </summary>
+ public CodedOutputStream(byte[] flatArray) : this(flatArray, 0, flatArray.Length)
+ {
+ }
+ /// <summary>
+ /// Creates a new CodedOutputStream that writes directly to the given
+ /// byte array slice. If more bytes are written than fit in the array,
+ /// OutOfSpaceException will be thrown.
+ /// </summary>
private CodedOutputStream(byte[] buffer, int offset, int length)
{
this.output = null;
@@ -85,40 +98,17 @@ namespace Google.Protobuf
/// <summary>
/// Creates a new CodedOutputStream which write to the given stream.
/// </summary>
- public static CodedOutputStream CreateInstance(Stream output)
+ public CodedOutputStream(Stream output) : this(output, DefaultBufferSize)
{
- return CreateInstance(output, DefaultBufferSize);
}
/// <summary>
/// Creates a new CodedOutputStream which write to the given stream and uses
/// the specified buffer size.
/// </summary>
- public static CodedOutputStream CreateInstance(Stream output, int bufferSize)
- {
- return new CodedOutputStream(output, new byte[bufferSize]);
- }
-
- /// <summary>
- /// Creates a new CodedOutputStream that writes directly to the given
- /// byte array. If more bytes are written than fit in the array,
- /// OutOfSpaceException will be thrown.
- /// </summary>
- public static CodedOutputStream CreateInstance(byte[] flatArray)
+ public CodedOutputStream(Stream output, int bufferSize) : this(output, new byte[bufferSize])
{
- return CreateInstance(flatArray, 0, flatArray.Length);
- }
-
- /// <summary>
- /// Creates a new CodedOutputStream that writes directly to the given
- /// byte array slice. If more bytes are written than fit in the array,
- /// OutOfSpaceException will be thrown.
- /// </summary>
- public static CodedOutputStream CreateInstance(byte[] flatArray, int offset, int length)
- {
- return new CodedOutputStream(flatArray, offset, length);
- }
-
+ }
#endregion
/// <summary>