From 0e0e0c97e7d5a70b3307c2fcea8793983b6e0680 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Mon, 3 Aug 2015 11:08:53 +0100 Subject: Expose Coded*Stream constructors directly. --- csharp/src/Google.Protobuf/CodedOutputStream.cs | 42 ++++++++++--------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'csharp/src/Google.Protobuf/CodedOutputStream.cs') 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 + /// + /// 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. + /// + public CodedOutputStream(byte[] flatArray) : this(flatArray, 0, flatArray.Length) + { + } + /// + /// 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. + /// private CodedOutputStream(byte[] buffer, int offset, int length) { this.output = null; @@ -85,40 +98,17 @@ namespace Google.Protobuf /// /// Creates a new CodedOutputStream which write to the given stream. /// - public static CodedOutputStream CreateInstance(Stream output) + public CodedOutputStream(Stream output) : this(output, DefaultBufferSize) { - return CreateInstance(output, DefaultBufferSize); } /// /// Creates a new CodedOutputStream which write to the given stream and uses /// the specified buffer size. /// - public static CodedOutputStream CreateInstance(Stream output, int bufferSize) - { - return new CodedOutputStream(output, new byte[bufferSize]); - } - - /// - /// 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. - /// - public static CodedOutputStream CreateInstance(byte[] flatArray) + public CodedOutputStream(Stream output, int bufferSize) : this(output, new byte[bufferSize]) { - return CreateInstance(flatArray, 0, flatArray.Length); - } - - /// - /// 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. - /// - public static CodedOutputStream CreateInstance(byte[] flatArray, int offset, int length) - { - return new CodedOutputStream(flatArray, offset, length); - } - + } #endregion /// -- cgit v1.2.3