Просмотр исходного кода

Server端Protobuf库引用前端的代码即可,因为Protobuf做了些修改,这样可以方便以后修改

tanghai 7 лет назад
Родитель
Сommit
25c7796c3a

+ 15 - 0
Server/Server.sln

@@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.Driver", "ThirdPart
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.Driver.Core", "ThirdParty\MongodbDriver\DotNetCoreDriver\MongoDB.Driver.Core\MongoDB.Driver.Core.csproj", "{46A590DE-EBA3-4928-AB78-5C514D08C9E7}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Protobuf", "ThirdParty\Google.Protobuf\Google.Protobuf.csproj", "{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -101,6 +103,18 @@ Global
 		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Release|x64.Build.0 = Release|Any CPU
 		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Release|x86.ActiveCfg = Release|Any CPU
 		{46A590DE-EBA3-4928-AB78-5C514D08C9E7}.Release|x86.Build.0 = Release|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Debug|x64.Build.0 = Debug|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Debug|x86.Build.0 = Debug|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Release|Any CPU.Build.0 = Release|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Release|x64.ActiveCfg = Release|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Release|x64.Build.0 = Release|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Release|x86.ActiveCfg = Release|Any CPU
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE}.Release|x86.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -110,6 +124,7 @@ Global
 		{817B2682-29D6-4BAC-9AA7-618DCCD8CBE5} = {6946DBCF-B81C-4B2A-A7C5-94A337D915C2}
 		{3FD1D683-59E8-47C4-9436-B3D856EFB094} = {6946DBCF-B81C-4B2A-A7C5-94A337D915C2}
 		{46A590DE-EBA3-4928-AB78-5C514D08C9E7} = {6946DBCF-B81C-4B2A-A7C5-94A337D915C2}
+		{02B4D7EC-AC40-4675-963E-53CAB9A86BDE} = {5D11E730-0CAA-4A47-BA1A-379004F0F6D9}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {EE120158-643A-409C-B8F2-5E654E4D6D70}

+ 0 - 79
Server/ThirdParty/Google.Protobuf/ByteArray.cs

@@ -1,79 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Provides a utility routine to copy small arrays much more quickly than Buffer.BlockCopy
-    /// </summary>
-    internal static class ByteArray
-    {
-        /// <summary>
-        /// The threshold above which you should use Buffer.BlockCopy rather than ByteArray.Copy
-        /// </summary>
-        private const int CopyThreshold = 12;
-
-        /// <summary>
-        /// Determines which copy routine to use based on the number of bytes to be copied.
-        /// </summary>
-        internal static void Copy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count)
-        {
-            if (count > CopyThreshold)
-            {
-                Buffer.BlockCopy(src, srcOffset, dst, dstOffset, count);
-            }
-            else
-            {
-                int stop = srcOffset + count;
-                for (int i = srcOffset; i < stop; i++)
-                {
-                    dst[dstOffset++] = src[i];
-                }
-            }
-        }
-
-        /// <summary>
-        /// Reverses the order of bytes in the array
-        /// </summary>
-        internal static void Reverse(byte[] bytes)
-        {
-            for (int first = 0, last = bytes.Length - 1; first < last; first++, last--)
-            {
-                byte temp = bytes[first];
-                bytes[first] = bytes[last];
-                bytes[last] = temp;
-            }
-        }
-    }
-}

+ 0 - 378
Server/ThirdParty/Google.Protobuf/ByteString.cs

@@ -1,378 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using Google.Protobuf.Compatibility;
-using MongoDB.Bson.Serialization.Attributes;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Immutable array of bytes.
-    /// </summary>
-    public sealed class ByteString : IEnumerable<byte>, IEquatable<ByteString>
-    {
-        private static readonly ByteString empty = new ByteString(new byte[0]);
-
-        public byte[] bytes;
-
-        /// <summary>
-        /// Unsafe operations that can cause IO Failure and/or other catestrophic side-effects.
-        /// </summary>
-        internal static class Unsafe
-        {
-            /// <summary>
-            /// Constructs a new ByteString from the given byte array. The array is
-            /// *not* copied, and must not be modified after this constructor is called.
-            /// </summary>
-            internal static ByteString FromBytes(byte[] bytes)
-            {
-                return new ByteString(bytes);
-            }
-
-            /// <summary>
-            /// Provides direct, unrestricted access to the bytes contained in this instance.
-            /// You must not modify or resize the byte array returned by this method.
-            /// </summary>
-            internal static byte[] GetBuffer(ByteString bytes)
-            {
-                return bytes.bytes;
-            }
-        }
-
-        /// <summary>
-        /// Internal use only.  Ensure that the provided array is not mutated and belongs to this instance.
-        /// </summary>
-        internal static ByteString AttachBytes(byte[] bytes)
-        {
-            return new ByteString(bytes);
-        }
-        
-        public ByteString()
-        {}
-
-        public ByteString(List<byte> list)
-        {
-            this.bytes = list.ToArray();
-        }
-        /// <summary>
-        /// Constructs a new ByteString from the given byte array. The array is
-        /// *not* copied, and must not be modified after this constructor is called.
-        /// </summary>
-        public ByteString(byte[] bytes)
-        {
-            this.bytes = bytes;
-        }
-
-        /// <summary>
-        /// Returns an empty ByteString.
-        /// </summary>
-        public static ByteString Empty
-        {
-            get { return empty; }
-        }
-
-        /// <summary>
-        /// Returns the length of this ByteString in bytes.
-        /// </summary>
-        [BsonIgnore]
-        public int Length
-        {
-            get { return bytes.Length; }
-        }
-
-        /// <summary>
-        /// Returns <c>true</c> if this byte string is empty, <c>false</c> otherwise.
-        /// </summary>
-        [BsonIgnore]
-        public bool IsEmpty
-        {
-            get { return Length == 0; }
-        }
-
-        /// <summary>
-        /// Converts this <see cref="ByteString"/> into a byte array.
-        /// </summary>
-        /// <remarks>The data is copied - changes to the returned array will not be reflected in this <c>ByteString</c>.</remarks>
-        /// <returns>A byte array with the same data as this <c>ByteString</c>.</returns>
-        public byte[] ToByteArray()
-        {
-            return (byte[]) bytes.Clone();
-        }
-
-        /// <summary>
-        /// Converts this <see cref="ByteString"/> into a standard base64 representation.
-        /// </summary>
-        /// <returns>A base64 representation of this <c>ByteString</c>.</returns>
-        public string ToBase64()
-        {
-            return Convert.ToBase64String(bytes);
-        }
-
-        /// <summary>
-        /// Constructs a <see cref="ByteString" /> from the Base64 Encoded String.
-        /// </summary>
-        public static ByteString FromBase64(string bytes)
-        {
-            // By handling the empty string explicitly, we not only optimize but we fix a
-            // problem on CF 2.0. See issue 61 for details.
-            return bytes == "" ? Empty : new ByteString(Convert.FromBase64String(bytes));
-        }
-
-        /// <summary>
-        /// Constructs a <see cref="ByteString"/> from data in the given stream, synchronously.
-        /// </summary>
-        /// <remarks>If successful, <paramref name="stream"/> will be read completely, from the position
-        /// at the start of the call.</remarks>
-        /// <param name="stream">The stream to copy into a ByteString.</param>
-        /// <returns>A ByteString with content read from the given stream.</returns>
-        public static ByteString FromStream(Stream stream)
-        {
-            ProtoPreconditions.CheckNotNull(stream, "stream");
-            int capacity = stream.CanSeek ? checked((int) (stream.Length - stream.Position)) : 0;
-            var memoryStream = new MemoryStream(capacity);
-            stream.CopyTo(memoryStream);
-
-            // Avoid an extra copy if we can.
-            byte[] bytes = memoryStream.Length == memoryStream.Capacity ? memoryStream.GetBuffer() : memoryStream.ToArray();
-
-            return AttachBytes(bytes);
-        }
-
-        /// <summary>
-        /// Constructs a <see cref="ByteString" /> from the given array. The contents
-        /// are copied, so further modifications to the array will not
-        /// be reflected in the returned ByteString.
-        /// This method can also be invoked in <c>ByteString.CopyFrom(0xaa, 0xbb, ...)</c> form
-        /// which is primarily useful for testing.
-        /// </summary>
-        public static ByteString CopyFrom(params byte[] bytes)
-        {
-            return new ByteString((byte[]) bytes.Clone());
-        }
-
-        /// <summary>
-        /// Constructs a <see cref="ByteString" /> from a portion of a byte array.
-        /// </summary>
-        public static ByteString CopyFrom(byte[] bytes, int offset, int count)
-        {
-            byte[] portion = new byte[count];
-            ByteArray.Copy(bytes, offset, portion, 0, count);
-            return new ByteString(portion);
-        }
-
-        /// <summary>
-        /// Creates a new <see cref="ByteString" /> by encoding the specified text with
-        /// the given encoding.
-        /// </summary>
-        public static ByteString CopyFrom(string text, Encoding encoding)
-        {
-            return new ByteString(encoding.GetBytes(text));
-        }
-
-        /// <summary>
-        /// Creates a new <see cref="ByteString" /> by encoding the specified text in UTF-8.
-        /// </summary>
-        public static ByteString CopyFromUtf8(string text)
-        {
-            return CopyFrom(text, Encoding.UTF8);
-        }
-
-        /// <summary>
-        /// Retuns the byte at the given index.
-        /// </summary>
-        [BsonIgnore]
-        public byte this[int index]
-        {
-            get { return bytes[index]; }
-        }
-
-        /// <summary>
-        /// Converts this <see cref="ByteString"/> into a string by applying the given encoding.
-        /// </summary>
-        /// <remarks>
-        /// This method should only be used to convert binary data which was the result of encoding
-        /// text with the given encoding.
-        /// </remarks>
-        /// <param name="encoding">The encoding to use to decode the binary data into text.</param>
-        /// <returns>The result of decoding the binary data with the given decoding.</returns>
-        public string ToString(Encoding encoding)
-        {
-            return encoding.GetString(bytes, 0, bytes.Length);
-        }
-
-        /// <summary>
-        /// Converts this <see cref="ByteString"/> into a string by applying the UTF-8 encoding.
-        /// </summary>
-        /// <remarks>
-        /// This method should only be used to convert binary data which was the result of encoding
-        /// text with UTF-8.
-        /// </remarks>
-        /// <returns>The result of decoding the binary data with the given decoding.</returns>
-        public string ToStringUtf8()
-        {
-            return ToString(Encoding.UTF8);
-        }
-
-        /// <summary>
-        /// Returns an iterator over the bytes in this <see cref="ByteString"/>.
-        /// </summary>
-        /// <returns>An iterator over the bytes in this object.</returns>
-        public IEnumerator<byte> GetEnumerator()
-        {
-            return ((IEnumerable<byte>) bytes).GetEnumerator();
-        }
-
-        /// <summary>
-        /// Returns an iterator over the bytes in this <see cref="ByteString"/>.
-        /// </summary>
-        /// <returns>An iterator over the bytes in this object.</returns>
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return GetEnumerator();
-        }
-
-        /// <summary>
-        /// Creates a CodedInputStream from this ByteString's data.
-        /// </summary>
-        public CodedInputStream CreateCodedInput()
-        {
-            // We trust CodedInputStream not to reveal the provided byte array or modify it
-            return new CodedInputStream(bytes);
-        }
-
-        /// <summary>
-        /// Compares two byte strings for equality.
-        /// </summary>
-        /// <param name="lhs">The first byte string to compare.</param>
-        /// <param name="rhs">The second byte string to compare.</param>
-        /// <returns><c>true</c> if the byte strings are equal; false otherwise.</returns>
-        public static bool operator ==(ByteString lhs, ByteString rhs)
-        {
-            if (ReferenceEquals(lhs, rhs))
-            {
-                return true;
-            }
-            if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
-            {
-                return false;
-            }
-            if (lhs.bytes.Length != rhs.bytes.Length)
-            {
-                return false;
-            }
-            for (int i = 0; i < lhs.Length; i++)
-            {
-                if (rhs.bytes[i] != lhs.bytes[i])
-                {
-                    return false;
-                }
-            }
-            return true;
-        }
-
-        /// <summary>
-        /// Compares two byte strings for inequality.
-        /// </summary>
-        /// <param name="lhs">The first byte string to compare.</param>
-        /// <param name="rhs">The second byte string to compare.</param>
-        /// <returns><c>false</c> if the byte strings are equal; true otherwise.</returns>
-        public static bool operator !=(ByteString lhs, ByteString rhs)
-        {
-            return !(lhs == rhs);
-        }
-
-        /// <summary>
-        /// Compares this byte string with another object.
-        /// </summary>
-        /// <param name="obj">The object to compare this with.</param>
-        /// <returns><c>true</c> if <paramref name="obj"/> refers to an equal <see cref="ByteString"/>; <c>false</c> otherwise.</returns>
-        public override bool Equals(object obj)
-        {
-            return this == (obj as ByteString);
-        }
-
-        /// <summary>
-        /// Returns a hash code for this object. Two equal byte strings
-        /// will return the same hash code.
-        /// </summary>
-        /// <returns>A hash code for this object.</returns>
-        public override int GetHashCode()
-        {
-            int ret = 23;
-            foreach (byte b in bytes)
-            {
-                ret = (ret * 31) + b;
-            }
-            return ret;
-        }
-
-        /// <summary>
-        /// Compares this byte string with another.
-        /// </summary>
-        /// <param name="other">The <see cref="ByteString"/> to compare this with.</param>
-        /// <returns><c>true</c> if <paramref name="other"/> refers to an equal byte string; <c>false</c> otherwise.</returns>
-        public bool Equals(ByteString other)
-        {
-            return this == other;
-        }
-
-        /// <summary>
-        /// Used internally by CodedOutputStream to avoid creating a copy for the write
-        /// </summary>
-        internal void WriteRawBytesTo(CodedOutputStream outputStream)
-        {
-            outputStream.WriteRawBytes(bytes, 0, bytes.Length);
-        }
-
-        /// <summary>
-        /// Copies the entire byte array to the destination array provided at the offset specified.
-        /// </summary>
-        public void CopyTo(byte[] array, int position)
-        {
-            ByteArray.Copy(bytes, 0, array, position, bytes.Length);
-        }
-
-        /// <summary>
-        /// Writes the entire byte array to the provided stream
-        /// </summary>
-        public void WriteTo(Stream outputStream)
-        {
-            outputStream.Write(bytes, 0, bytes.Length);
-        }
-    }
-}

+ 0 - 1274
Server/ThirdParty/Google.Protobuf/CodedInputStream.cs

@@ -1,1274 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using Google.Protobuf.Collections;
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Reads and decodes protocol message fields.
-    /// </summary>
-    /// <remarks>
-    /// <para>
-    /// This class is generally used by generated code to read appropriate
-    /// primitives from the stream. It effectively encapsulates the lowest
-    /// levels of protocol buffer format.
-    /// </para>
-    /// <para>
-    /// Repeated fields and map fields are not handled by this class; use <see cref="RepeatedField{T}"/>
-    /// and <see cref="MapField{TKey, TValue}"/> to serialize such fields.
-    /// </para>
-    /// </remarks>
-    public sealed class CodedInputStream : IDisposable
-    {
-        /// <summary>
-        /// Whether to leave the underlying stream open when disposing of this stream.
-        /// This is always true when there's no stream.
-        /// </summary>
-        private readonly bool leaveOpen;
-
-        /// <summary>
-        /// Buffer of data read from the stream or provided at construction time.
-        /// </summary>
-        private readonly byte[] buffer;
-
-        /// <summary>
-        /// The index of the buffer at which we need to refill from the stream (if there is one).
-        /// </summary>
-        private int bufferSize;
-
-        private int bufferSizeAfterLimit = 0;
-        /// <summary>
-        /// The position within the current buffer (i.e. the next byte to read)
-        /// </summary>
-        private int bufferPos = 0;
-
-        /// <summary>
-        /// The stream to read further input from, or null if the byte array buffer was provided
-        /// directly on construction, with no further data available.
-        /// </summary>
-        private readonly Stream input;
-
-        /// <summary>
-        /// The last tag we read. 0 indicates we've read to the end of the stream
-        /// (or haven't read anything yet).
-        /// </summary>
-        private uint lastTag = 0;
-
-        /// <summary>
-        /// The next tag, used to store the value read by PeekTag.
-        /// </summary>
-        private uint nextTag = 0;
-        private bool hasNextTag = false;
-
-        internal const int DefaultRecursionLimit = 64;
-        internal const int DefaultSizeLimit = 64 << 20; // 64MB
-        internal const int BufferSize = 4096;
-
-        /// <summary>
-        /// The total number of bytes read before the current buffer. The
-        /// total bytes read up to the current position can be computed as
-        /// totalBytesRetired + bufferPos.
-        /// </summary>
-        private int totalBytesRetired = 0;
-
-        /// <summary>
-        /// The absolute position of the end of the current message.
-        /// </summary> 
-        private int currentLimit = int.MaxValue;
-
-        private int recursionDepth = 0;
-
-        private readonly int recursionLimit;
-        private readonly int sizeLimit;
-
-        #region Construction
-        // Note that the checks are performed such that we don't end up checking obviously-valid things
-        // like non-null references for arrays we've just created.
-
-        /// <summary>
-        /// Creates a new CodedInputStream reading data from the given byte array.
-        /// </summary>
-        public CodedInputStream(byte[] buffer) : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), 0, buffer.Length, true)
-        {            
-        }
-
-        /// <summary>
-        /// Creates a new <see cref="CodedInputStream"/> that reads from the given byte array slice.
-        /// </summary>
-        public CodedInputStream(byte[] buffer, int offset, int length)
-            : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length, true)
-        {            
-            if (offset < 0 || offset > buffer.Length)
-            {
-                throw new ArgumentOutOfRangeException("offset", "Offset must be within the buffer");
-            }
-            if (length < 0 || offset + length > buffer.Length)
-            {
-                throw new ArgumentOutOfRangeException("length", "Length must be non-negative and within the buffer");
-            }
-        }
-
-        /// <summary>
-        /// Creates a new <see cref="CodedInputStream"/> reading data from the given stream, which will be disposed
-        /// when the returned object is disposed.
-        /// </summary>
-        /// <param name="input">The stream to read from.</param>
-        public CodedInputStream(Stream input) : this(input, false)
-        {
-        }
-
-        /// <summary>
-        /// Creates a new <see cref="CodedInputStream"/> reading data from the given stream.
-        /// </summary>
-        /// <param name="input">The stream to read from.</param>
-        /// <param name="leaveOpen"><c>true</c> to leave <paramref name="input"/> open when the returned
-        /// <c cref="CodedInputStream"/> is disposed; <c>false</c> to dispose of the given stream when the
-        /// returned object is disposed.</param>
-        public CodedInputStream(Stream input, bool leaveOpen)
-            : this(ProtoPreconditions.CheckNotNull(input, "input"), new byte[BufferSize], 0, 0, leaveOpen)
-        {
-        }
-        
-        /// <summary>
-        /// Creates a new CodedInputStream reading data from the given
-        /// stream and buffer, using the default limits.
-        /// </summary>
-        internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, bool leaveOpen)
-        {
-            this.input = input;
-            this.buffer = buffer;
-            this.bufferPos = bufferPos;
-            this.bufferSize = bufferSize;
-            this.sizeLimit = DefaultSizeLimit;
-            this.recursionLimit = DefaultRecursionLimit;
-            this.leaveOpen = leaveOpen;
-        }
-
-        /// <summary>
-        /// Creates a new CodedInputStream reading data from the given
-        /// stream and buffer, using the specified limits.
-        /// </summary>
-        /// <remarks>
-        /// This chains to the version with the default limits instead of vice versa to avoid
-        /// having to check that the default values are valid every time.
-        /// </remarks>
-        internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, int sizeLimit, int recursionLimit, bool leaveOpen)
-            : this(input, buffer, bufferPos, bufferSize, leaveOpen)
-        {
-            if (sizeLimit <= 0)
-            {
-                throw new ArgumentOutOfRangeException("sizeLimit", "Size limit must be positive");
-            }
-            if (recursionLimit <= 0)
-            {
-                throw new ArgumentOutOfRangeException("recursionLimit!", "Recursion limit must be positive");
-            }
-            this.sizeLimit = sizeLimit;
-            this.recursionLimit = recursionLimit;
-        }
-        #endregion
-
-        /// <summary>
-        /// Creates a <see cref="CodedInputStream"/> with the specified size and recursion limits, reading
-        /// from an input stream.
-        /// </summary>
-        /// <remarks>
-        /// This method exists separately from the constructor to reduce the number of constructor overloads.
-        /// It is likely to be used considerably less frequently than the constructors, as the default limits
-        /// are suitable for most use cases.
-        /// </remarks>
-        /// <param name="input">The input stream to read from</param>
-        /// <param name="sizeLimit">The total limit of data to read from the stream.</param>
-        /// <param name="recursionLimit">The maximum recursion depth to allow while reading.</param>
-        /// <returns>A <c>CodedInputStream</c> reading from <paramref name="input"/> with the specified size
-        /// and recursion limits.</returns>
-        public static CodedInputStream CreateWithLimits(Stream input, int sizeLimit, int recursionLimit)
-        {
-            // Note: we may want an overload accepting leaveOpen
-            return new CodedInputStream(input, new byte[BufferSize], 0, 0, sizeLimit, recursionLimit, false);
-        }
-
-        /// <summary>
-        /// Returns the current position in the input stream, or the position in the input buffer
-        /// </summary>
-        public long Position 
-        {
-            get
-            {
-                if (input != null)
-                {
-                    return input.Position - ((bufferSize + bufferSizeAfterLimit) - bufferPos);
-                }
-                return bufferPos;
-            }
-        }
-
-        /// <summary>
-        /// Returns the last tag read, or 0 if no tags have been read or we've read beyond
-        /// the end of the stream.
-        /// </summary>
-        internal uint LastTag { get { return lastTag; } }
-
-        /// <summary>
-        /// Returns the size limit for this stream.
-        /// </summary>
-        /// <remarks>
-        /// This limit is applied when reading from the underlying stream, as a sanity check. It is
-        /// not applied when reading from a byte array data source without an underlying stream.
-        /// The default value is 64MB.
-        /// </remarks>
-        /// <value>
-        /// The size limit.
-        /// </value>
-        public int SizeLimit { get { return sizeLimit; } }
-
-        /// <summary>
-        /// Returns the recursion limit for this stream. This limit is applied whilst reading messages,
-        /// to avoid maliciously-recursive data.
-        /// </summary>
-        /// <remarks>
-        /// The default limit is 64.
-        /// </remarks>
-        /// <value>
-        /// The recursion limit for this stream.
-        /// </value>
-        public int RecursionLimit { get { return recursionLimit; } }
-
-        /// <summary>
-        /// Disposes of this instance, potentially closing any underlying stream.
-        /// </summary>
-        /// <remarks>
-        /// As there is no flushing to perform here, disposing of a <see cref="CodedInputStream"/> which
-        /// was constructed with the <c>leaveOpen</c> option parameter set to <c>true</c> (or one which
-        /// was constructed to read from a byte array) has no effect.
-        /// </remarks>
-        public void Dispose()
-        {
-            if (!leaveOpen)
-            {
-                input.Dispose();
-            }
-        }
-
-        #region Validation
-        /// <summary>
-        /// Verifies that the last call to ReadTag() returned tag 0 - in other words,
-        /// we've reached the end of the stream when we expected to.
-        /// </summary>
-        /// <exception cref="InvalidProtocolBufferException">The 
-        /// tag read was not the one specified</exception>
-        internal void CheckReadEndOfStreamTag()
-        {
-            if (lastTag != 0)
-            {
-                throw InvalidProtocolBufferException.MoreDataAvailable();
-            }
-        }
-        #endregion
-
-        #region Reading of tags etc
-
-        /// <summary>
-        /// Peeks at the next field tag. This is like calling <see cref="ReadTag"/>, but the
-        /// tag is not consumed. (So a subsequent call to <see cref="ReadTag"/> will return the
-        /// same value.)
-        /// </summary>
-        public uint PeekTag()
-        {
-            if (hasNextTag)
-            {
-                return nextTag;
-            }
-
-            uint savedLast = lastTag;
-            nextTag = ReadTag();
-            hasNextTag = true;
-            lastTag = savedLast; // Undo the side effect of ReadTag
-            return nextTag;
-        }
-
-        /// <summary>
-        /// Reads a field tag, returning the tag of 0 for "end of stream".
-        /// </summary>
-        /// <remarks>
-        /// If this method returns 0, it doesn't necessarily mean the end of all
-        /// the data in this CodedInputStream; it may be the end of the logical stream
-        /// for an embedded message, for example.
-        /// </remarks>
-        /// <returns>The next field tag, or 0 for end of stream. (0 is never a valid tag.)</returns>
-        public uint ReadTag()
-        {
-            if (hasNextTag)
-            {
-                lastTag = nextTag;
-                hasNextTag = false;
-                return lastTag;
-            }
-
-            // Optimize for the incredibly common case of having at least two bytes left in the buffer,
-            // and those two bytes being enough to get the tag. This will be true for fields up to 4095.
-            if (bufferPos + 2 <= bufferSize)
-            {
-                int tmp = buffer[bufferPos++];
-                if (tmp < 128)
-                {
-                    lastTag = (uint)tmp;
-                }
-                else
-                {
-                    int result = tmp & 0x7f;
-                    if ((tmp = buffer[bufferPos++]) < 128)
-                    {
-                        result |= tmp << 7;
-                        lastTag = (uint) result;
-                    }
-                    else
-                    {
-                        // Nope, rewind and go the potentially slow route.
-                        bufferPos -= 2;
-                        lastTag = ReadRawVarint32();
-                    }
-                }
-            }
-            else
-            {
-                if (IsAtEnd)
-                {
-                    lastTag = 0;
-                    return 0; // This is the only case in which we return 0.
-                }
-
-                lastTag = ReadRawVarint32();
-            }
-            if (lastTag == 0)
-            {
-                // If we actually read zero, that's not a valid tag.
-                throw InvalidProtocolBufferException.InvalidTag();
-            }
-            return lastTag;
-        }
-
-        /// <summary>
-        /// Skips the data for the field with the tag we've just read.
-        /// This should be called directly after <see cref="ReadTag"/>, when
-        /// the caller wishes to skip an unknown field.
-        /// </summary>
-        /// <remarks>
-        /// This method throws <see cref="InvalidProtocolBufferException"/> if the last-read tag was an end-group tag.
-        /// If a caller wishes to skip a group, they should skip the whole group, by calling this method after reading the
-        /// start-group tag. This behavior allows callers to call this method on any field they don't understand, correctly
-        /// resulting in an error if an end-group tag has not been paired with an earlier start-group tag.
-        /// </remarks>
-        /// <exception cref="InvalidProtocolBufferException">The last tag was an end-group tag</exception>
-        /// <exception cref="InvalidOperationException">The last read operation read to the end of the logical stream</exception>
-        public void SkipLastField()
-        {
-            if (lastTag == 0)
-            {
-                throw new InvalidOperationException("SkipLastField cannot be called at the end of a stream");
-            }
-            switch (WireFormat.GetTagWireType(lastTag))
-            {
-                case WireFormat.WireType.StartGroup:
-                    SkipGroup(lastTag);
-                    break;
-                case WireFormat.WireType.EndGroup:
-                    throw new InvalidProtocolBufferException("SkipLastField called on an end-group tag, indicating that the corresponding start-group was missing");
-                case WireFormat.WireType.Fixed32:
-                    ReadFixed32();
-                    break;
-                case WireFormat.WireType.Fixed64:
-                    ReadFixed64();
-                    break;
-                case WireFormat.WireType.LengthDelimited:
-                    var length = ReadLength();
-                    SkipRawBytes(length);
-                    break;
-                case WireFormat.WireType.Varint:
-                    ReadRawVarint32();
-                    break;
-            }
-        }
-
-        private void SkipGroup(uint startGroupTag)
-        {
-            // Note: Currently we expect this to be the way that groups are read. We could put the recursion
-            // depth changes into the ReadTag method instead, potentially...
-            recursionDepth++;
-            if (recursionDepth >= recursionLimit)
-            {
-                throw InvalidProtocolBufferException.RecursionLimitExceeded();
-            }
-            uint tag;
-            while (true)
-            {
-                tag = ReadTag();
-                if (tag == 0)
-                {
-                    throw InvalidProtocolBufferException.TruncatedMessage();
-                }
-                // Can't call SkipLastField for this case- that would throw.
-                if (WireFormat.GetTagWireType(tag) == WireFormat.WireType.EndGroup)
-                {
-                    break;
-                }
-                // This recursion will allow us to handle nested groups.
-                SkipLastField();
-            }
-            int startField = WireFormat.GetTagFieldNumber(startGroupTag);
-            int endField = WireFormat.GetTagFieldNumber(tag);
-            if (startField != endField)
-            {
-                throw new InvalidProtocolBufferException("Mismatched end-group tag. Started with field " + startField + "; ended with field " + endField);
-            }
-            recursionDepth--;
-        }
-
-        /// <summary>
-        /// Reads a double field from the stream.
-        /// </summary>
-        public double ReadDouble()
-        {
-            return BitConverter.Int64BitsToDouble((long) ReadRawLittleEndian64());
-        }
-
-        /// <summary>
-        /// Reads a float field from the stream.
-        /// </summary>
-        public float ReadFloat()
-        {
-            if (BitConverter.IsLittleEndian && 4 <= bufferSize - bufferPos)
-            {
-                float ret = BitConverter.ToSingle(buffer, bufferPos);
-                bufferPos += 4;
-                return ret;
-            }
-            else
-            {
-                byte[] rawBytes = ReadRawBytes(4);
-                if (!BitConverter.IsLittleEndian)
-                {
-                    ByteArray.Reverse(rawBytes);
-                }
-                return BitConverter.ToSingle(rawBytes, 0);
-            }
-        }
-
-        /// <summary>
-        /// Reads a uint64 field from the stream.
-        /// </summary>
-        public ulong ReadUInt64()
-        {
-            return ReadRawVarint64();
-        }
-
-        /// <summary>
-        /// Reads an int64 field from the stream.
-        /// </summary>
-        public long ReadInt64()
-        {
-            return (long) ReadRawVarint64();
-        }
-
-        /// <summary>
-        /// Reads an int32 field from the stream.
-        /// </summary>
-        public int ReadInt32()
-        {
-            return (int) ReadRawVarint32();
-        }
-
-        /// <summary>
-        /// Reads a fixed64 field from the stream.
-        /// </summary>
-        public ulong ReadFixed64()
-        {
-            return ReadRawLittleEndian64();
-        }
-
-        /// <summary>
-        /// Reads a fixed32 field from the stream.
-        /// </summary>
-        public uint ReadFixed32()
-        {
-            return ReadRawLittleEndian32();
-        }
-
-        /// <summary>
-        /// Reads a bool field from the stream.
-        /// </summary>
-        public bool ReadBool()
-        {
-            return ReadRawVarint32() != 0;
-        }
-
-        /// <summary>
-        /// Reads a string field from the stream.
-        /// </summary>
-        public string ReadString()
-        {
-            int length = ReadLength();
-            // No need to read any data for an empty string.
-            if (length == 0)
-            {
-                return "";
-            }
-            if (length <= bufferSize - bufferPos)
-            {
-                // Fast path:  We already have the bytes in a contiguous buffer, so
-                //   just copy directly from it.
-                String result = CodedOutputStream.Utf8Encoding.GetString(buffer, bufferPos, length);
-                bufferPos += length;
-                return result;
-            }
-            // Slow path: Build a byte array first then copy it.
-            return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(length), 0, length);
-        }
-
-        /// <summary>
-        /// Reads an embedded message field value from the stream.
-        /// </summary>   
-        public void ReadMessage(IMessage builder)
-        {
-            int length = ReadLength();
-            if (recursionDepth >= recursionLimit)
-            {
-                throw InvalidProtocolBufferException.RecursionLimitExceeded();
-            }
-            int oldLimit = PushLimit(length);
-            ++recursionDepth;
-            builder.MergeFrom(this);
-            CheckReadEndOfStreamTag();
-            // Check that we've read exactly as much data as expected.
-            if (!ReachedLimit)
-            {
-                throw InvalidProtocolBufferException.TruncatedMessage();
-            }
-            --recursionDepth;
-            PopLimit(oldLimit);
-        }
-
-        /// <summary>
-        /// Reads a bytes field value from the stream.
-        /// </summary>   
-        public ByteString ReadBytes()
-        {
-            int length = ReadLength();
-            if (length <= bufferSize - bufferPos && length > 0)
-            {
-                // Fast path:  We already have the bytes in a contiguous buffer, so
-                //   just copy directly from it.
-                ByteString result = ByteString.CopyFrom(buffer, bufferPos, length);
-                bufferPos += length;
-                return result;
-            }
-            else
-            {
-                // Slow path:  Build a byte array and attach it to a new ByteString.
-                return ByteString.AttachBytes(ReadRawBytes(length));
-            }
-        }
-
-        /// <summary>
-        /// Reads a uint32 field value from the stream.
-        /// </summary>   
-        public uint ReadUInt32()
-        {
-            return ReadRawVarint32();
-        }
-
-        /// <summary>
-        /// Reads an enum field value from the stream.
-        /// </summary>   
-        public int ReadEnum()
-        {
-            // Currently just a pass-through, but it's nice to separate it logically from WriteInt32.
-            return (int) ReadRawVarint32();
-        }
-
-        /// <summary>
-        /// Reads an sfixed32 field value from the stream.
-        /// </summary>   
-        public int ReadSFixed32()
-        {
-            return (int) ReadRawLittleEndian32();
-        }
-
-        /// <summary>
-        /// Reads an sfixed64 field value from the stream.
-        /// </summary>   
-        public long ReadSFixed64()
-        {
-            return (long) ReadRawLittleEndian64();
-        }
-
-        /// <summary>
-        /// Reads an sint32 field value from the stream.
-        /// </summary>   
-        public int ReadSInt32()
-        {
-            return DecodeZigZag32(ReadRawVarint32());
-        }
-
-        /// <summary>
-        /// Reads an sint64 field value from the stream.
-        /// </summary>   
-        public long ReadSInt64()
-        {
-            return DecodeZigZag64(ReadRawVarint64());
-        }
-
-        /// <summary>
-        /// Reads a length for length-delimited data.
-        /// </summary>
-        /// <remarks>
-        /// This is internally just reading a varint, but this method exists
-        /// to make the calling code clearer.
-        /// </remarks>
-        public int ReadLength()
-        {
-            return (int) ReadRawVarint32();
-        }
-
-        /// <summary>
-        /// Peeks at the next tag in the stream. If it matches <paramref name="tag"/>,
-        /// the tag is consumed and the method returns <c>true</c>; otherwise, the
-        /// stream is left in the original position and the method returns <c>false</c>.
-        /// </summary>
-        public bool MaybeConsumeTag(uint tag)
-        {
-            if (PeekTag() == tag)
-            {
-                hasNextTag = false;
-                return true;
-            }
-            return false;
-        }
-
-        #endregion
-
-        #region Underlying reading primitives
-
-        /// <summary>
-        /// Same code as ReadRawVarint32, but read each byte individually, checking for
-        /// buffer overflow.
-        /// </summary>
-        private uint SlowReadRawVarint32()
-        {
-            int tmp = ReadRawByte();
-            if (tmp < 128)
-            {
-                return (uint) tmp;
-            }
-            int result = tmp & 0x7f;
-            if ((tmp = ReadRawByte()) < 128)
-            {
-                result |= tmp << 7;
-            }
-            else
-            {
-                result |= (tmp & 0x7f) << 7;
-                if ((tmp = ReadRawByte()) < 128)
-                {
-                    result |= tmp << 14;
-                }
-                else
-                {
-                    result |= (tmp & 0x7f) << 14;
-                    if ((tmp = ReadRawByte()) < 128)
-                    {
-                        result |= tmp << 21;
-                    }
-                    else
-                    {
-                        result |= (tmp & 0x7f) << 21;
-                        result |= (tmp = ReadRawByte()) << 28;
-                        if (tmp >= 128)
-                        {
-                            // Discard upper 32 bits.
-                            for (int i = 0; i < 5; i++)
-                            {
-                                if (ReadRawByte() < 128)
-                                {
-                                    return (uint) result;
-                                }
-                            }
-                            throw InvalidProtocolBufferException.MalformedVarint();
-                        }
-                    }
-                }
-            }
-            return (uint) result;
-        }
-
-        /// <summary>
-        /// Reads a raw Varint from the stream.  If larger than 32 bits, discard the upper bits.
-        /// This method is optimised for the case where we've got lots of data in the buffer.
-        /// That means we can check the size just once, then just read directly from the buffer
-        /// without constant rechecking of the buffer length.
-        /// </summary>
-        internal uint ReadRawVarint32()
-        {
-            if (bufferPos + 5 > bufferSize)
-            {
-                return SlowReadRawVarint32();
-            }
-
-            int tmp = buffer[bufferPos++];
-            if (tmp < 128)
-            {
-                return (uint) tmp;
-            }
-            int result = tmp & 0x7f;
-            if ((tmp = buffer[bufferPos++]) < 128)
-            {
-                result |= tmp << 7;
-            }
-            else
-            {
-                result |= (tmp & 0x7f) << 7;
-                if ((tmp = buffer[bufferPos++]) < 128)
-                {
-                    result |= tmp << 14;
-                }
-                else
-                {
-                    result |= (tmp & 0x7f) << 14;
-                    if ((tmp = buffer[bufferPos++]) < 128)
-                    {
-                        result |= tmp << 21;
-                    }
-                    else
-                    {
-                        result |= (tmp & 0x7f) << 21;
-                        result |= (tmp = buffer[bufferPos++]) << 28;
-                        if (tmp >= 128)
-                        {
-                            // Discard upper 32 bits.
-                            // Note that this has to use ReadRawByte() as we only ensure we've
-                            // got at least 5 bytes at the start of the method. This lets us
-                            // use the fast path in more cases, and we rarely hit this section of code.
-                            for (int i = 0; i < 5; i++)
-                            {
-                                if (ReadRawByte() < 128)
-                                {
-                                    return (uint) result;
-                                }
-                            }
-                            throw InvalidProtocolBufferException.MalformedVarint();
-                        }
-                    }
-                }
-            }
-            return (uint) result;
-        }
-
-        /// <summary>
-        /// Reads a varint from the input one byte at a time, so that it does not
-        /// read any bytes after the end of the varint. If you simply wrapped the
-        /// stream in a CodedInputStream and used ReadRawVarint32(Stream)
-        /// then you would probably end up reading past the end of the varint since
-        /// CodedInputStream buffers its input.
-        /// </summary>
-        /// <param name="input"></param>
-        /// <returns></returns>
-        internal static uint ReadRawVarint32(Stream input)
-        {
-            int result = 0;
-            int offset = 0;
-            for (; offset < 32; offset += 7)
-            {
-                int b = input.ReadByte();
-                if (b == -1)
-                {
-                    throw InvalidProtocolBufferException.TruncatedMessage();
-                }
-                result |= (b & 0x7f) << offset;
-                if ((b & 0x80) == 0)
-                {
-                    return (uint) result;
-                }
-            }
-            // Keep reading up to 64 bits.
-            for (; offset < 64; offset += 7)
-            {
-                int b = input.ReadByte();
-                if (b == -1)
-                {
-                    throw InvalidProtocolBufferException.TruncatedMessage();
-                }
-                if ((b & 0x80) == 0)
-                {
-                    return (uint) result;
-                }
-            }
-            throw InvalidProtocolBufferException.MalformedVarint();
-        }
-
-        /// <summary>
-        /// Reads a raw varint from the stream.
-        /// </summary>
-        internal ulong ReadRawVarint64()
-        {
-            int shift = 0;
-            ulong result = 0;
-            while (shift < 64)
-            {
-                byte b = ReadRawByte();
-                result |= (ulong) (b & 0x7F) << shift;
-                if ((b & 0x80) == 0)
-                {
-                    return result;
-                }
-                shift += 7;
-            }
-            throw InvalidProtocolBufferException.MalformedVarint();
-        }
-
-        /// <summary>
-        /// Reads a 32-bit little-endian integer from the stream.
-        /// </summary>
-        internal uint ReadRawLittleEndian32()
-        {
-            uint b1 = ReadRawByte();
-            uint b2 = ReadRawByte();
-            uint b3 = ReadRawByte();
-            uint b4 = ReadRawByte();
-            return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24);
-        }
-
-        /// <summary>
-        /// Reads a 64-bit little-endian integer from the stream.
-        /// </summary>
-        internal ulong ReadRawLittleEndian64()
-        {
-            ulong b1 = ReadRawByte();
-            ulong b2 = ReadRawByte();
-            ulong b3 = ReadRawByte();
-            ulong b4 = ReadRawByte();
-            ulong b5 = ReadRawByte();
-            ulong b6 = ReadRawByte();
-            ulong b7 = ReadRawByte();
-            ulong b8 = ReadRawByte();
-            return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24)
-                   | (b5 << 32) | (b6 << 40) | (b7 << 48) | (b8 << 56);
-        }
-
-        /// <summary>
-        /// Decode a 32-bit value with ZigZag encoding.
-        /// </summary>
-        /// <remarks>
-        /// ZigZag encodes signed integers into values that can be efficiently
-        /// encoded with varint.  (Otherwise, negative values must be 
-        /// sign-extended to 64 bits to be varint encoded, thus always taking
-        /// 10 bytes on the wire.)
-        /// </remarks>
-        internal static int DecodeZigZag32(uint n)
-        {
-            return (int)(n >> 1) ^ -(int)(n & 1);
-        }
-
-        /// <summary>
-        /// Decode a 32-bit value with ZigZag encoding.
-        /// </summary>
-        /// <remarks>
-        /// ZigZag encodes signed integers into values that can be efficiently
-        /// encoded with varint.  (Otherwise, negative values must be 
-        /// sign-extended to 64 bits to be varint encoded, thus always taking
-        /// 10 bytes on the wire.)
-        /// </remarks>
-        internal static long DecodeZigZag64(ulong n)
-        {
-            return (long)(n >> 1) ^ -(long)(n & 1);
-        }
-        #endregion
-
-        #region Internal reading and buffer management
-
-        /// <summary>
-        /// Sets currentLimit to (current position) + byteLimit. This is called
-        /// when descending into a length-delimited embedded message. The previous
-        /// limit is returned.
-        /// </summary>
-        /// <returns>The old limit.</returns>
-        internal int PushLimit(int byteLimit)
-        {
-            if (byteLimit < 0)
-            {
-                throw InvalidProtocolBufferException.NegativeSize();
-            }
-            byteLimit += totalBytesRetired + bufferPos;
-            int oldLimit = currentLimit;
-            if (byteLimit > oldLimit)
-            {
-                throw InvalidProtocolBufferException.TruncatedMessage();
-            }
-            currentLimit = byteLimit;
-
-            RecomputeBufferSizeAfterLimit();
-
-            return oldLimit;
-        }
-
-        private void RecomputeBufferSizeAfterLimit()
-        {
-            bufferSize += bufferSizeAfterLimit;
-            int bufferEnd = totalBytesRetired + bufferSize;
-            if (bufferEnd > currentLimit)
-            {
-                // Limit is in current buffer.
-                bufferSizeAfterLimit = bufferEnd - currentLimit;
-                bufferSize -= bufferSizeAfterLimit;
-            }
-            else
-            {
-                bufferSizeAfterLimit = 0;
-            }
-        }
-
-        /// <summary>
-        /// Discards the current limit, returning the previous limit.
-        /// </summary>
-        internal void PopLimit(int oldLimit)
-        {
-            currentLimit = oldLimit;
-            RecomputeBufferSizeAfterLimit();
-        }
-
-        /// <summary>
-        /// Returns whether or not all the data before the limit has been read.
-        /// </summary>
-        /// <returns></returns>
-        internal bool ReachedLimit
-        {
-            get
-            {
-                if (currentLimit == int.MaxValue)
-                {
-                    return false;
-                }
-                int currentAbsolutePosition = totalBytesRetired + bufferPos;
-                return currentAbsolutePosition >= currentLimit;
-            }
-        }
-
-        /// <summary>
-        /// Returns true if the stream has reached the end of the input. This is the
-        /// case if either the end of the underlying input source has been reached or
-        /// the stream has reached a limit created using PushLimit.
-        /// </summary>
-        public bool IsAtEnd
-        {
-            get { return bufferPos == bufferSize && !RefillBuffer(false); }
-        }
-
-        /// <summary>
-        /// Called when buffer is empty to read more bytes from the
-        /// input.  If <paramref name="mustSucceed"/> is true, RefillBuffer() gurantees that
-        /// either there will be at least one byte in the buffer when it returns
-        /// or it will throw an exception.  If <paramref name="mustSucceed"/> is false,
-        /// RefillBuffer() returns false if no more bytes were available.
-        /// </summary>
-        /// <param name="mustSucceed"></param>
-        /// <returns></returns>
-        private bool RefillBuffer(bool mustSucceed)
-        {
-            if (bufferPos < bufferSize)
-            {
-                throw new InvalidOperationException("RefillBuffer() called when buffer wasn't empty.");
-            }
-
-            if (totalBytesRetired + bufferSize == currentLimit)
-            {
-                // Oops, we hit a limit.
-                if (mustSucceed)
-                {
-                    throw InvalidProtocolBufferException.TruncatedMessage();
-                }
-                else
-                {
-                    return false;
-                }
-            }
-
-            totalBytesRetired += bufferSize;
-
-            bufferPos = 0;
-            bufferSize = (input == null) ? 0 : input.Read(buffer, 0, buffer.Length);
-            if (bufferSize < 0)
-            {
-                throw new InvalidOperationException("Stream.Read returned a negative count");
-            }
-            if (bufferSize == 0)
-            {
-                if (mustSucceed)
-                {
-                    throw InvalidProtocolBufferException.TruncatedMessage();
-                }
-                else
-                {
-                    return false;
-                }
-            }
-            else
-            {
-                RecomputeBufferSizeAfterLimit();
-                int totalBytesRead =
-                    totalBytesRetired + bufferSize + bufferSizeAfterLimit;
-                if (totalBytesRead > sizeLimit || totalBytesRead < 0)
-                {
-                    throw InvalidProtocolBufferException.SizeLimitExceeded();
-                }
-                return true;
-            }
-        }
-
-        /// <summary>
-        /// Read one byte from the input.
-        /// </summary>
-        /// <exception cref="InvalidProtocolBufferException">
-        /// the end of the stream or the current limit was reached
-        /// </exception>
-        internal byte ReadRawByte()
-        {
-            if (bufferPos == bufferSize)
-            {
-                RefillBuffer(true);
-            }
-            return buffer[bufferPos++];
-        }
-
-        /// <summary>
-        /// Reads a fixed size of bytes from the input.
-        /// </summary>
-        /// <exception cref="InvalidProtocolBufferException">
-        /// the end of the stream or the current limit was reached
-        /// </exception>
-        internal byte[] ReadRawBytes(int size)
-        {
-            if (size < 0)
-            {
-                throw InvalidProtocolBufferException.NegativeSize();
-            }
-
-            if (totalBytesRetired + bufferPos + size > currentLimit)
-            {
-                // Read to the end of the stream (up to the current limit) anyway.
-                SkipRawBytes(currentLimit - totalBytesRetired - bufferPos);
-                // Then fail.
-                throw InvalidProtocolBufferException.TruncatedMessage();
-            }
-
-            if (size <= bufferSize - bufferPos)
-            {
-                // We have all the bytes we need already.
-                byte[] bytes = new byte[size];
-                ByteArray.Copy(buffer, bufferPos, bytes, 0, size);
-                bufferPos += size;
-                return bytes;
-            }
-            else if (size < buffer.Length)
-            {
-                // Reading more bytes than are in the buffer, but not an excessive number
-                // of bytes.  We can safely allocate the resulting array ahead of time.
-
-                // First copy what we have.
-                byte[] bytes = new byte[size];
-                int pos = bufferSize - bufferPos;
-                ByteArray.Copy(buffer, bufferPos, bytes, 0, pos);
-                bufferPos = bufferSize;
-
-                // We want to use RefillBuffer() and then copy from the buffer into our
-                // byte array rather than reading directly into our byte array because
-                // the input may be unbuffered.
-                RefillBuffer(true);
-
-                while (size - pos > bufferSize)
-                {
-                    Buffer.BlockCopy(buffer, 0, bytes, pos, bufferSize);
-                    pos += bufferSize;
-                    bufferPos = bufferSize;
-                    RefillBuffer(true);
-                }
-
-                ByteArray.Copy(buffer, 0, bytes, pos, size - pos);
-                bufferPos = size - pos;
-
-                return bytes;
-            }
-            else
-            {
-                // The size is very large.  For security reasons, we can't allocate the
-                // entire byte array yet.  The size comes directly from the input, so a
-                // maliciously-crafted message could provide a bogus very large size in
-                // order to trick the app into allocating a lot of memory.  We avoid this
-                // by allocating and reading only a small chunk at a time, so that the
-                // malicious message must actually *be* extremely large to cause
-                // problems.  Meanwhile, we limit the allowed size of a message elsewhere.
-
-                // Remember the buffer markers since we'll have to copy the bytes out of
-                // it later.
-                int originalBufferPos = bufferPos;
-                int originalBufferSize = bufferSize;
-
-                // Mark the current buffer consumed.
-                totalBytesRetired += bufferSize;
-                bufferPos = 0;
-                bufferSize = 0;
-
-                // Read all the rest of the bytes we need.
-                int sizeLeft = size - (originalBufferSize - originalBufferPos);
-                List<byte[]> chunks = new List<byte[]>();
-
-                while (sizeLeft > 0)
-                {
-                    byte[] chunk = new byte[Math.Min(sizeLeft, buffer.Length)];
-                    int pos = 0;
-                    while (pos < chunk.Length)
-                    {
-                        int n = (input == null) ? -1 : input.Read(chunk, pos, chunk.Length - pos);
-                        if (n <= 0)
-                        {
-                            throw InvalidProtocolBufferException.TruncatedMessage();
-                        }
-                        totalBytesRetired += n;
-                        pos += n;
-                    }
-                    sizeLeft -= chunk.Length;
-                    chunks.Add(chunk);
-                }
-
-                // OK, got everything.  Now concatenate it all into one buffer.
-                byte[] bytes = new byte[size];
-
-                // Start by copying the leftover bytes from this.buffer.
-                int newPos = originalBufferSize - originalBufferPos;
-                ByteArray.Copy(buffer, originalBufferPos, bytes, 0, newPos);
-
-                // And now all the chunks.
-                foreach (byte[] chunk in chunks)
-                {
-                    Buffer.BlockCopy(chunk, 0, bytes, newPos, chunk.Length);
-                    newPos += chunk.Length;
-                }
-
-                // Done.
-                return bytes;
-            }
-        }
-
-        /// <summary>
-        /// Reads and discards <paramref name="size"/> bytes.
-        /// </summary>
-        /// <exception cref="InvalidProtocolBufferException">the end of the stream
-        /// or the current limit was reached</exception>
-        private void SkipRawBytes(int size)
-        {
-            if (size < 0)
-            {
-                throw InvalidProtocolBufferException.NegativeSize();
-            }
-
-            if (totalBytesRetired + bufferPos + size > currentLimit)
-            {
-                // Read to the end of the stream anyway.
-                SkipRawBytes(currentLimit - totalBytesRetired - bufferPos);
-                // Then fail.
-                throw InvalidProtocolBufferException.TruncatedMessage();
-            }
-
-            if (size <= bufferSize - bufferPos)
-            {
-                // We have all the bytes we need already.
-                bufferPos += size;
-            }
-            else
-            {
-                // Skipping more bytes than are in the buffer.  First skip what we have.
-                int pos = bufferSize - bufferPos;
-
-                // ROK 5/7/2013 Issue #54: should retire all bytes in buffer (bufferSize)
-                // totalBytesRetired += pos;
-                totalBytesRetired += bufferSize;
-                
-                bufferPos = 0;
-                bufferSize = 0;
-
-                // Then skip directly from the InputStream for the rest.
-                if (pos < size)
-                {
-                    if (input == null)
-                    {
-                        throw InvalidProtocolBufferException.TruncatedMessage();
-                    }
-                    SkipImpl(size - pos);
-                    totalBytesRetired += size - pos;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Abstraction of skipping to cope with streams which can't really skip.
-        /// </summary>
-        private void SkipImpl(int amountToSkip)
-        {
-            if (input.CanSeek)
-            {
-                long previousPosition = input.Position;
-                input.Position += amountToSkip;
-                if (input.Position != previousPosition + amountToSkip)
-                {
-                    throw InvalidProtocolBufferException.TruncatedMessage();
-                }
-            }
-            else
-            {
-                byte[] skipBuffer = new byte[Math.Min(1024, amountToSkip)];
-                while (amountToSkip > 0)
-                {
-                    int bytesRead = input.Read(skipBuffer, 0, Math.Min(skipBuffer.Length, amountToSkip));
-                    if (bytesRead <= 0)
-                    {
-                        throw InvalidProtocolBufferException.TruncatedMessage();
-                    }
-                    amountToSkip -= bytesRead;
-                }
-            }
-        }
-
-        #endregion
-    }
-}

+ 0 - 304
Server/ThirdParty/Google.Protobuf/CodedOutputStream.ComputeSize.cs

@@ -1,304 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-
-namespace Google.Protobuf
-{
-    // This part of CodedOutputStream provides all the static entry points that are used
-    // by generated code and internally to compute the size of messages prior to being
-    // written to an instance of CodedOutputStream.
-    public sealed partial class CodedOutputStream
-    {
-        private const int LittleEndian64Size = 8;
-        private const int LittleEndian32Size = 4;        
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// double field, including the tag.
-        /// </summary>
-        public static int ComputeDoubleSize(double value)
-        {
-            return LittleEndian64Size;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// float field, including the tag.
-        /// </summary>
-        public static int ComputeFloatSize(float value)
-        {
-            return LittleEndian32Size;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// uint64 field, including the tag.
-        /// </summary>
-        public static int ComputeUInt64Size(ulong value)
-        {
-            return ComputeRawVarint64Size(value);
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode an
-        /// int64 field, including the tag.
-        /// </summary>
-        public static int ComputeInt64Size(long value)
-        {
-            return ComputeRawVarint64Size((ulong) value);
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode an
-        /// int32 field, including the tag.
-        /// </summary>
-        public static int ComputeInt32Size(int value)
-        {
-            if (value >= 0)
-            {
-                return ComputeRawVarint32Size((uint) value);
-            }
-            else
-            {
-                // Must sign-extend.
-                return 10;
-            }
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// fixed64 field, including the tag.
-        /// </summary>
-        public static int ComputeFixed64Size(ulong value)
-        {
-            return LittleEndian64Size;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// fixed32 field, including the tag.
-        /// </summary>
-        public static int ComputeFixed32Size(uint value)
-        {
-            return LittleEndian32Size;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// bool field, including the tag.
-        /// </summary>
-        public static int ComputeBoolSize(bool value)
-        {
-            return 1;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// string field, including the tag.
-        /// </summary>
-        public static int ComputeStringSize(String value)
-        {
-            int byteArraySize = Utf8Encoding.GetByteCount(value);
-            return ComputeLengthSize(byteArraySize) + byteArraySize;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// group field, including the tag.
-        /// </summary>
-        public static int ComputeGroupSize(IMessage value)
-        {
-            return value.CalculateSize();
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode an
-        /// embedded message field, including the tag.
-        /// </summary>
-        public static int ComputeMessageSize(IMessage value)
-        {
-            int size = value.CalculateSize();
-            return ComputeLengthSize(size) + size;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// bytes field, including the tag.
-        /// </summary>
-        public static int ComputeBytesSize(ByteString value)
-        {
-            return ComputeLengthSize(value.Length) + value.Length;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// uint32 field, including the tag.
-        /// </summary>
-        public static int ComputeUInt32Size(uint value)
-        {
-            return ComputeRawVarint32Size(value);
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a
-        /// enum field, including the tag. The caller is responsible for
-        /// converting the enum value to its numeric value.
-        /// </summary>
-        public static int ComputeEnumSize(int value)
-        {
-            // Currently just a pass-through, but it's nice to separate it logically.
-            return ComputeInt32Size(value);
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode an
-        /// sfixed32 field, including the tag.
-        /// </summary>
-        public static int ComputeSFixed32Size(int value)
-        {
-            return LittleEndian32Size;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode an
-        /// sfixed64 field, including the tag.
-        /// </summary>
-        public static int ComputeSFixed64Size(long value)
-        {
-            return LittleEndian64Size;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode an
-        /// sint32 field, including the tag.
-        /// </summary>
-        public static int ComputeSInt32Size(int value)
-        {
-            return ComputeRawVarint32Size(EncodeZigZag32(value));
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode an
-        /// sint64 field, including the tag.
-        /// </summary>
-        public static int ComputeSInt64Size(long value)
-        {
-            return ComputeRawVarint64Size(EncodeZigZag64(value));
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a length,
-        /// as written by <see cref="WriteLength"/>.
-        /// </summary>
-        public static int ComputeLengthSize(int length)
-        {
-            return ComputeRawVarint32Size((uint) length);
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a varint.
-        /// </summary>
-        public static int ComputeRawVarint32Size(uint value)
-        {
-            if ((value & (0xffffffff << 7)) == 0)
-            {
-                return 1;
-            }
-            if ((value & (0xffffffff << 14)) == 0)
-            {
-                return 2;
-            }
-            if ((value & (0xffffffff << 21)) == 0)
-            {
-                return 3;
-            }
-            if ((value & (0xffffffff << 28)) == 0)
-            {
-                return 4;
-            }
-            return 5;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a varint.
-        /// </summary>
-        public static int ComputeRawVarint64Size(ulong value)
-        {
-            if ((value & (0xffffffffffffffffL << 7)) == 0)
-            {
-                return 1;
-            }
-            if ((value & (0xffffffffffffffffL << 14)) == 0)
-            {
-                return 2;
-            }
-            if ((value & (0xffffffffffffffffL << 21)) == 0)
-            {
-                return 3;
-            }
-            if ((value & (0xffffffffffffffffL << 28)) == 0)
-            {
-                return 4;
-            }
-            if ((value & (0xffffffffffffffffL << 35)) == 0)
-            {
-                return 5;
-            }
-            if ((value & (0xffffffffffffffffL << 42)) == 0)
-            {
-                return 6;
-            }
-            if ((value & (0xffffffffffffffffL << 49)) == 0)
-            {
-                return 7;
-            }
-            if ((value & (0xffffffffffffffffL << 56)) == 0)
-            {
-                return 8;
-            }
-            if ((value & (0xffffffffffffffffL << 63)) == 0)
-            {
-                return 9;
-            }
-            return 10;
-        }
-
-        /// <summary>
-        /// Computes the number of bytes that would be needed to encode a tag.
-        /// </summary>
-        public static int ComputeTagSize(int fieldNumber)
-        {
-            return ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, 0));
-        }
-    }
-}

+ 0 - 761
Server/ThirdParty/Google.Protobuf/CodedOutputStream.cs

@@ -1,761 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using Google.Protobuf.Collections;
-using System;
-using System.IO;
-using System.Text;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Encodes and writes protocol message fields.
-    /// </summary>
-    /// <remarks>
-    /// <para>
-    /// This class is generally used by generated code to write appropriate
-    /// primitives to the stream. It effectively encapsulates the lowest
-    /// levels of protocol buffer format. Unlike some other implementations,
-    /// this does not include combined "write tag and value" methods. Generated
-    /// code knows the exact byte representations of the tags they're going to write,
-    /// so there's no need to re-encode them each time. Manually-written code calling
-    /// this class should just call one of the <c>WriteTag</c> overloads before each value.
-    /// </para>
-    /// <para>
-    /// Repeated fields and map fields are not handled by this class; use <c>RepeatedField&lt;T&gt;</c>
-    /// and <c>MapField&lt;TKey, TValue&gt;</c> to serialize such fields.
-    /// </para>
-    /// </remarks>
-    public sealed partial class CodedOutputStream : IDisposable
-    {
-        // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.)
-        internal static readonly Encoding Utf8Encoding = Encoding.UTF8;
-
-        /// <summary>
-        /// The buffer size used by CreateInstance(Stream).
-        /// </summary>
-        public static readonly int DefaultBufferSize = 4096;
-
-        private readonly bool leaveOpen;
-        private readonly byte[] buffer;
-        private readonly int limit;
-        private int position;
-        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;
-            this.buffer = buffer;
-            this.position = offset;
-            this.limit = offset + length;
-            leaveOpen = true; // Simple way of avoiding trying to dispose of a null reference
-        }
-
-        private CodedOutputStream(Stream output, byte[] buffer, bool leaveOpen)
-        {
-            this.output = ProtoPreconditions.CheckNotNull(output, "output");
-            this.buffer = buffer;
-            this.position = 0;
-            this.limit = buffer.Length;
-            this.leaveOpen = leaveOpen;
-        }
-
-        /// <summary>
-        /// Creates a new <see cref="CodedOutputStream" /> which write to the given stream, and disposes of that
-        /// stream when the returned <c>CodedOutputStream</c> is disposed.
-        /// </summary>
-        /// <param name="output">The stream to write to. It will be disposed when the returned <c>CodedOutputStream is disposed.</c></param>
-        public CodedOutputStream(Stream output) : this(output, DefaultBufferSize, false)
-        {
-        }
-
-        /// <summary>
-        /// Creates a new CodedOutputStream which write to the given stream and uses
-        /// the specified buffer size.
-        /// </summary>
-        /// <param name="output">The stream to write to. It will be disposed when the returned <c>CodedOutputStream is disposed.</c></param>
-        /// <param name="bufferSize">The size of buffer to use internally.</param>
-        public CodedOutputStream(Stream output, int bufferSize) : this(output, new byte[bufferSize], false)
-        {
-        }
-
-        /// <summary>
-        /// Creates a new CodedOutputStream which write to the given stream.
-        /// </summary>
-        /// <param name="output">The stream to write to.</param>
-        /// <param name="leaveOpen">If <c>true</c>, <paramref name="output"/> is left open when the returned <c>CodedOutputStream</c> is disposed;
-        /// if <c>false</c>, the provided stream is disposed as well.</param>
-        public CodedOutputStream(Stream output, bool leaveOpen) : this(output, DefaultBufferSize, leaveOpen)
-        {
-        }
-
-        /// <summary>
-        /// Creates a new CodedOutputStream which write to the given stream and uses
-        /// the specified buffer size.
-        /// </summary>
-        /// <param name="output">The stream to write to.</param>
-        /// <param name="bufferSize">The size of buffer to use internally.</param>
-        /// <param name="leaveOpen">If <c>true</c>, <paramref name="output"/> is left open when the returned <c>CodedOutputStream</c> is disposed;
-        /// if <c>false</c>, the provided stream is disposed as well.</param>
-        public CodedOutputStream(Stream output, int bufferSize, bool leaveOpen) : this(output, new byte[bufferSize], leaveOpen)
-        {
-        }
-        #endregion
-
-        /// <summary>
-        /// Returns the current position in the stream, or the position in the output buffer
-        /// </summary>
-        public long Position
-        {
-            get
-            {
-                if (output != null)
-                {
-                    return output.Position + position;
-                }
-                return position;
-            }
-        }
-
-        #region Writing of values (not including tags)
-
-        /// <summary>
-        /// Writes a double field value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteDouble(double value)
-        {
-            WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value));
-        }
-
-        /// <summary>
-        /// Writes a float field value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteFloat(float value)
-        {
-            byte[] rawBytes = BitConverter.GetBytes(value);
-            if (!BitConverter.IsLittleEndian)
-            {
-                ByteArray.Reverse(rawBytes);
-            }
-
-            if (limit - position >= 4)
-            {
-                buffer[position++] = rawBytes[0];
-                buffer[position++] = rawBytes[1];
-                buffer[position++] = rawBytes[2];
-                buffer[position++] = rawBytes[3];
-            }
-            else
-            {
-                WriteRawBytes(rawBytes, 0, 4);
-            }
-        }
-
-        /// <summary>
-        /// Writes a uint64 field value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteUInt64(ulong value)
-        {
-            WriteRawVarint64(value);
-        }
-
-        /// <summary>
-        /// Writes an int64 field value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteInt64(long value)
-        {
-            WriteRawVarint64((ulong) value);
-        }
-
-        /// <summary>
-        /// Writes an int32 field value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteInt32(int value)
-        {
-            if (value >= 0)
-            {
-                WriteRawVarint32((uint) value);
-            }
-            else
-            {
-                // Must sign-extend.
-                WriteRawVarint64((ulong) value);
-            }
-        }
-
-        /// <summary>
-        /// Writes a fixed64 field value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteFixed64(ulong value)
-        {
-            WriteRawLittleEndian64(value);
-        }
-
-        /// <summary>
-        /// Writes a fixed32 field value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteFixed32(uint value)
-        {
-            WriteRawLittleEndian32(value);
-        }
-
-        /// <summary>
-        /// Writes a bool field value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteBool(bool value)
-        {
-            WriteRawByte(value ? (byte) 1 : (byte) 0);
-        }
-
-        /// <summary>
-        /// Writes a string field value, without a tag, to the stream.
-        /// The data is length-prefixed.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteString(string value)
-        {
-            // Optimise the case where we have enough space to write
-            // the string directly to the buffer, which should be common.
-            int length = Utf8Encoding.GetByteCount(value);
-            WriteLength(length);
-            if (limit - position >= length)
-            {
-                if (length == value.Length) // Must be all ASCII...
-                {
-                    for (int i = 0; i < length; i++)
-                    {
-                        buffer[position + i] = (byte)value[i];
-                    }
-                }
-                else
-                {
-                    Utf8Encoding.GetBytes(value, 0, value.Length, buffer, position);
-                }
-                position += length;
-            }
-            else
-            {
-                byte[] bytes = Utf8Encoding.GetBytes(value);
-                WriteRawBytes(bytes);
-            }
-        }
-
-        /// <summary>
-        /// Writes a message, without a tag, to the stream.
-        /// The data is length-prefixed.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteMessage(IMessage value)
-        {
-            WriteLength(value.CalculateSize());
-            value.WriteTo(this);
-        }
-
-        /// <summary>
-        /// Write a byte string, without a tag, to the stream.
-        /// The data is length-prefixed.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteBytes(ByteString value)
-        {
-            WriteLength(value.Length);
-            value.WriteRawBytesTo(this);
-        }
-
-        /// <summary>
-        /// Writes a uint32 value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteUInt32(uint value)
-        {
-            WriteRawVarint32(value);
-        }
-
-        /// <summary>
-        /// Writes an enum value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteEnum(int value)
-        {
-            WriteInt32(value);
-        }
-
-        /// <summary>
-        /// Writes an sfixed32 value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write.</param>
-        public void WriteSFixed32(int value)
-        {
-            WriteRawLittleEndian32((uint) value);
-        }
-
-        /// <summary>
-        /// Writes an sfixed64 value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteSFixed64(long value)
-        {
-            WriteRawLittleEndian64((ulong) value);
-        }
-
-        /// <summary>
-        /// Writes an sint32 value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteSInt32(int value)
-        {
-            WriteRawVarint32(EncodeZigZag32(value));
-        }
-
-        /// <summary>
-        /// Writes an sint64 value, without a tag, to the stream.
-        /// </summary>
-        /// <param name="value">The value to write</param>
-        public void WriteSInt64(long value)
-        {
-            WriteRawVarint64(EncodeZigZag64(value));
-        }
-
-        /// <summary>
-        /// Writes a length (in bytes) for length-delimited data.
-        /// </summary>
-        /// <remarks>
-        /// This method simply writes a rawint, but exists for clarity in calling code.
-        /// </remarks>
-        /// <param name="length">Length value, in bytes.</param>
-        public void WriteLength(int length)
-        {
-            WriteRawVarint32((uint) length);
-        }
-
-        #endregion
-
-        #region Raw tag writing
-        /// <summary>
-        /// Encodes and writes a tag.
-        /// </summary>
-        /// <param name="fieldNumber">The number of the field to write the tag for</param>
-        /// <param name="type">The wire format type of the tag to write</param>
-        public void WriteTag(int fieldNumber, WireFormat.WireType type)
-        {
-            WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type));
-        }
-
-        /// <summary>
-        /// Writes an already-encoded tag.
-        /// </summary>
-        /// <param name="tag">The encoded tag</param>
-        public void WriteTag(uint tag)
-        {
-            WriteRawVarint32(tag);
-        }
-
-        /// <summary>
-        /// Writes the given single-byte tag directly to the stream.
-        /// </summary>
-        /// <param name="b1">The encoded tag</param>
-        public void WriteRawTag(byte b1)
-        {
-            WriteRawByte(b1);
-        }
-
-        /// <summary>
-        /// Writes the given two-byte tag directly to the stream.
-        /// </summary>
-        /// <param name="b1">The first byte of the encoded tag</param>
-        /// <param name="b2">The second byte of the encoded tag</param>
-        public void WriteRawTag(byte b1, byte b2)
-        {
-            WriteRawByte(b1);
-            WriteRawByte(b2);
-        }
-
-        /// <summary>
-        /// Writes the given three-byte tag directly to the stream.
-        /// </summary>
-        /// <param name="b1">The first byte of the encoded tag</param>
-        /// <param name="b2">The second byte of the encoded tag</param>
-        /// <param name="b3">The third byte of the encoded tag</param>
-        public void WriteRawTag(byte b1, byte b2, byte b3)
-        {
-            WriteRawByte(b1);
-            WriteRawByte(b2);
-            WriteRawByte(b3);
-        }
-
-        /// <summary>
-        /// Writes the given four-byte tag directly to the stream.
-        /// </summary>
-        /// <param name="b1">The first byte of the encoded tag</param>
-        /// <param name="b2">The second byte of the encoded tag</param>
-        /// <param name="b3">The third byte of the encoded tag</param>
-        /// <param name="b4">The fourth byte of the encoded tag</param>
-        public void WriteRawTag(byte b1, byte b2, byte b3, byte b4)
-        {
-            WriteRawByte(b1);
-            WriteRawByte(b2);
-            WriteRawByte(b3);
-            WriteRawByte(b4);
-        }
-
-        /// <summary>
-        /// Writes the given five-byte tag directly to the stream.
-        /// </summary>
-        /// <param name="b1">The first byte of the encoded tag</param>
-        /// <param name="b2">The second byte of the encoded tag</param>
-        /// <param name="b3">The third byte of the encoded tag</param>
-        /// <param name="b4">The fourth byte of the encoded tag</param>
-        /// <param name="b5">The fifth byte of the encoded tag</param>
-        public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5)
-        {
-            WriteRawByte(b1);
-            WriteRawByte(b2);
-            WriteRawByte(b3);
-            WriteRawByte(b4);
-            WriteRawByte(b5);
-        }
-        #endregion
-
-        #region Underlying writing primitives
-        /// <summary>
-        /// Writes a 32 bit value as a varint. The fast route is taken when
-        /// there's enough buffer space left to whizz through without checking
-        /// for each byte; otherwise, we resort to calling WriteRawByte each time.
-        /// </summary>
-        internal void WriteRawVarint32(uint value)
-        {
-            // Optimize for the common case of a single byte value
-            if (value < 128 && position < limit)
-            {
-                buffer[position++] = (byte)value;
-                return;
-            }
-
-            while (value > 127 && position < limit)
-            {
-                buffer[position++] = (byte) ((value & 0x7F) | 0x80);
-                value >>= 7;
-            }
-            while (value > 127)
-            {
-                WriteRawByte((byte) ((value & 0x7F) | 0x80));
-                value >>= 7;
-            }
-            if (position < limit)
-            {
-                buffer[position++] = (byte) value;
-            }
-            else
-            {
-                WriteRawByte((byte) value);
-            }
-        }
-
-        internal void WriteRawVarint64(ulong value)
-        {
-            while (value > 127 && position < limit)
-            {
-                buffer[position++] = (byte) ((value & 0x7F) | 0x80);
-                value >>= 7;
-            }
-            while (value > 127)
-            {
-                WriteRawByte((byte) ((value & 0x7F) | 0x80));
-                value >>= 7;
-            }
-            if (position < limit)
-            {
-                buffer[position++] = (byte) value;
-            }
-            else
-            {
-                WriteRawByte((byte) value);
-            }
-        }
-
-        internal void WriteRawLittleEndian32(uint value)
-        {
-            if (position + 4 > limit)
-            {
-                WriteRawByte((byte) value);
-                WriteRawByte((byte) (value >> 8));
-                WriteRawByte((byte) (value >> 16));
-                WriteRawByte((byte) (value >> 24));
-            }
-            else
-            {
-                buffer[position++] = ((byte) value);
-                buffer[position++] = ((byte) (value >> 8));
-                buffer[position++] = ((byte) (value >> 16));
-                buffer[position++] = ((byte) (value >> 24));
-            }
-        }
-
-        internal void WriteRawLittleEndian64(ulong value)
-        {
-            if (position + 8 > limit)
-            {
-                WriteRawByte((byte) value);
-                WriteRawByte((byte) (value >> 8));
-                WriteRawByte((byte) (value >> 16));
-                WriteRawByte((byte) (value >> 24));
-                WriteRawByte((byte) (value >> 32));
-                WriteRawByte((byte) (value >> 40));
-                WriteRawByte((byte) (value >> 48));
-                WriteRawByte((byte) (value >> 56));
-            }
-            else
-            {
-                buffer[position++] = ((byte) value);
-                buffer[position++] = ((byte) (value >> 8));
-                buffer[position++] = ((byte) (value >> 16));
-                buffer[position++] = ((byte) (value >> 24));
-                buffer[position++] = ((byte) (value >> 32));
-                buffer[position++] = ((byte) (value >> 40));
-                buffer[position++] = ((byte) (value >> 48));
-                buffer[position++] = ((byte) (value >> 56));
-            }
-        }
-
-        internal void WriteRawByte(byte value)
-        {
-            if (position == limit)
-            {
-                RefreshBuffer();
-            }
-
-            buffer[position++] = value;
-        }
-
-        internal void WriteRawByte(uint value)
-        {
-            WriteRawByte((byte) value);
-        }
-
-        /// <summary>
-        /// Writes out an array of bytes.
-        /// </summary>
-        internal void WriteRawBytes(byte[] value)
-        {
-            WriteRawBytes(value, 0, value.Length);
-        }
-
-        /// <summary>
-        /// Writes out part of an array of bytes.
-        /// </summary>
-        internal void WriteRawBytes(byte[] value, int offset, int length)
-        {
-            if (limit - position >= length)
-            {
-                ByteArray.Copy(value, offset, buffer, position, length);
-                // We have room in the current buffer.
-                position += length;
-            }
-            else
-            {
-                // Write extends past current buffer.  Fill the rest of this buffer and
-                // flush.
-                int bytesWritten = limit - position;
-                ByteArray.Copy(value, offset, buffer, position, bytesWritten);
-                offset += bytesWritten;
-                length -= bytesWritten;
-                position = limit;
-                RefreshBuffer();
-
-                // Now deal with the rest.
-                // Since we have an output stream, this is our buffer
-                // and buffer offset == 0
-                if (length <= limit)
-                {
-                    // Fits in new buffer.
-                    ByteArray.Copy(value, offset, buffer, 0, length);
-                    position = length;
-                }
-                else
-                {
-                    // Write is very big.  Let's do it all at once.
-                    output.Write(value, offset, length);
-                }
-            }
-        }
-
-        #endregion
-
-        /// <summary>
-        /// Encode a 32-bit value with ZigZag encoding.
-        /// </summary>
-        /// <remarks>
-        /// ZigZag encodes signed integers into values that can be efficiently
-        /// encoded with varint.  (Otherwise, negative values must be 
-        /// sign-extended to 64 bits to be varint encoded, thus always taking
-        /// 10 bytes on the wire.)
-        /// </remarks>
-        internal static uint EncodeZigZag32(int n)
-        {
-            // Note:  the right-shift must be arithmetic
-            return (uint) ((n << 1) ^ (n >> 31));
-        }
-
-        /// <summary>
-        /// Encode a 64-bit value with ZigZag encoding.
-        /// </summary>
-        /// <remarks>
-        /// ZigZag encodes signed integers into values that can be efficiently
-        /// encoded with varint.  (Otherwise, negative values must be 
-        /// sign-extended to 64 bits to be varint encoded, thus always taking
-        /// 10 bytes on the wire.)
-        /// </remarks>
-        internal static ulong EncodeZigZag64(long n)
-        {
-            return (ulong) ((n << 1) ^ (n >> 63));
-        }
-
-        private void RefreshBuffer()
-        {
-            if (output == null)
-            {
-                // We're writing to a single buffer.
-                throw new OutOfSpaceException();
-            }
-
-            // Since we have an output stream, this is our buffer
-            // and buffer offset == 0
-            output.Write(buffer, 0, position);
-            position = 0;
-        }
-
-        /// <summary>
-        /// Indicates that a CodedOutputStream wrapping a flat byte array
-        /// ran out of space.
-        /// </summary>
-        public sealed class OutOfSpaceException : IOException
-        {
-            internal OutOfSpaceException()
-                : base("CodedOutputStream was writing to a flat byte array and ran out of space.")
-            {
-            }
-        }
-
-        /// <summary>
-        /// Flushes any buffered data and optionally closes the underlying stream, if any.
-        /// </summary>
-        /// <remarks>
-        /// <para>
-        /// By default, any underlying stream is closed by this method. To configure this behaviour,
-        /// use a constructor overload with a <c>leaveOpen</c> parameter. If this instance does not
-        /// have an underlying stream, this method does nothing.
-        /// </para>
-        /// <para>
-        /// For the sake of efficiency, calling this method does not prevent future write calls - but
-        /// if a later write ends up writing to a stream which has been disposed, that is likely to
-        /// fail. It is recommend that you not call any other methods after this.
-        /// </para>
-        /// </remarks>
-        public void Dispose()
-        {
-            Flush();
-            if (!leaveOpen)
-            {
-                output.Dispose();
-            }
-        }
-
-        /// <summary>
-        /// Flushes any buffered data to the underlying stream (if there is one).
-        /// </summary>
-        public void Flush()
-        {
-            if (output != null)
-            {
-                RefreshBuffer();
-            }
-        }
-
-        /// <summary>
-        /// Verifies that SpaceLeft returns zero. It's common to create a byte array
-        /// that is exactly big enough to hold a message, then write to it with
-        /// a CodedOutputStream. Calling CheckNoSpaceLeft after writing verifies that
-        /// the message was actually as big as expected, which can help bugs.
-        /// </summary>
-        public void CheckNoSpaceLeft()
-        {
-            if (SpaceLeft != 0)
-            {
-                throw new InvalidOperationException("Did not write as much data as expected.");
-            }
-        }
-
-        /// <summary>
-        /// If writing to a flat array, returns the space left in the array. Otherwise,
-        /// throws an InvalidOperationException.
-        /// </summary>
-        public int SpaceLeft
-        {
-            get
-            {
-                if (output == null)
-                {
-                    return limit - position;
-                }
-                else
-                {
-                    throw new InvalidOperationException(
-                        "SpaceLeft can only be called on CodedOutputStreams that are " +
-                        "writing to a flat array.");
-                }
-            }
-        }
-    }
-}

+ 0 - 580
Server/ThirdParty/Google.Protobuf/Collections/RepeatedField.cs

@@ -1,580 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-
-namespace Google.Protobuf.Collections
-{
-    /// <summary>
-    /// The contents of a repeated field: essentially, a collection with some extra
-    /// restrictions (no null values) and capabilities (deep cloning).
-    /// </summary>
-    /// <remarks>
-    /// This implementation does not generally prohibit the use of types which are not
-    /// supported by Protocol Buffers but nor does it guarantee that all operations will work in such cases.
-    /// </remarks>
-    /// <typeparam name="T">The element type of the repeated field.</typeparam>
-    public sealed class RepeatedField<T> : IList<T>, IList 
-    {
-        private static readonly T[] EmptyArray = new T[0];
-        private const int MinArraySize = 8;
-
-        public T[] array = EmptyArray;
-        public int count = 0;
-
-        /// <summary>
-        /// Adds the entries from the given input stream, decoding them with the specified codec.
-        /// </summary>
-        /// <param name="input">The input stream to read from.</param>
-        /// <param name="codec">The codec to use in order to read each entry.</param>
-        public void AddEntriesFrom(CodedInputStream input, FieldCodec<T> codec)
-        {
-            // TODO: Inline some of the Add code, so we can avoid checking the size on every
-            // iteration.
-            uint tag = input.LastTag;
-            var reader = codec.ValueReader;
-            // Non-nullable value types can be packed or not.
-            if (FieldCodec<T>.IsPackedRepeatedField(tag))
-            {
-                int length = input.ReadLength();
-                if (length > 0)
-                {
-                    int oldLimit = input.PushLimit(length);
-                    while (!input.ReachedLimit)
-                    {
-                        Add(reader(input));
-                    }
-                    input.PopLimit(oldLimit);
-                }
-                // Empty packed field. Odd, but valid - just ignore.
-            }
-            else
-            {
-                // Not packed... (possibly not packable)
-                do
-                {
-                    Add(reader(input));
-                } while (input.MaybeConsumeTag(tag));
-            }
-        }
-
-        /// <summary>
-        /// Calculates the size of this collection based on the given codec.
-        /// </summary>
-        /// <param name="codec">The codec to use when encoding each field.</param>
-        /// <returns>The number of bytes that would be written to a <see cref="CodedOutputStream"/> by <see cref="WriteTo"/>,
-        /// using the same codec.</returns>
-        public int CalculateSize(FieldCodec<T> codec)
-        {
-            if (count == 0)
-            {
-                return 0;
-            }
-            uint tag = codec.Tag;
-            if (codec.PackedRepeatedField)
-            {
-                int dataSize = CalculatePackedDataSize(codec);
-                return CodedOutputStream.ComputeRawVarint32Size(tag) +
-                    CodedOutputStream.ComputeLengthSize(dataSize) +
-                    dataSize;
-            }
-            else
-            {
-                var sizeCalculator = codec.ValueSizeCalculator;
-                int size = count * CodedOutputStream.ComputeRawVarint32Size(tag);
-                for (int i = 0; i < count; i++)
-                {
-                    size += sizeCalculator(array[i]);
-                }
-                return size;
-            }
-        }
-
-        private int CalculatePackedDataSize(FieldCodec<T> codec)
-        {
-            int fixedSize = codec.FixedSize;
-            if (fixedSize == 0)
-            {
-                var calculator = codec.ValueSizeCalculator;
-                int tmp = 0;
-                for (int i = 0; i < count; i++)
-                {
-                    tmp += calculator(array[i]);
-                }
-                return tmp;
-            }
-            else
-            {
-                return fixedSize * Count;
-            }
-        }
-
-        /// <summary>
-        /// Writes the contents of this collection to the given <see cref="CodedOutputStream"/>,
-        /// encoding each value using the specified codec.
-        /// </summary>
-        /// <param name="output">The output stream to write to.</param>
-        /// <param name="codec">The codec to use when encoding each value.</param>
-        public void WriteTo(CodedOutputStream output, FieldCodec<T> codec)
-        {
-            if (count == 0)
-            {
-                return;
-            }
-            var writer = codec.ValueWriter;
-            var tag = codec.Tag;
-            if (codec.PackedRepeatedField)
-            {
-                // Packed primitive type
-                uint size = (uint)CalculatePackedDataSize(codec);
-                output.WriteTag(tag);
-                output.WriteRawVarint32(size);
-                for (int i = 0; i < count; i++)
-                {
-                    writer(output, array[i]);
-                }
-            }
-            else
-            {
-                // Not packed: a simple tag/value pair for each value.
-                // Can't use codec.WriteTagAndValue, as that omits default values.
-                for (int i = 0; i < count; i++)
-                {
-                    output.WriteTag(tag);
-                    writer(output, array[i]);
-                }
-            }
-        }
-
-        private void EnsureSize(int size)
-        {
-            if (array.Length < size)
-            {
-                size = Math.Max(size, MinArraySize);
-                int newSize = Math.Max(array.Length * 2, size);
-                var tmp = new T[newSize];
-                Array.Copy(array, 0, tmp, 0, array.Length);
-                array = tmp;
-            }
-        }
-
-        /// <summary>
-        /// Adds the specified item to the collection.
-        /// </summary>
-        /// <param name="item">The item to add.</param>
-        public void Add(T item)
-        {
-            ProtoPreconditions.CheckNotNullUnconstrained(item, "item");
-            EnsureSize(count + 1);
-            array[count++] = item;
-        }
-
-        /// <summary>
-        /// Removes all items from the collection.
-        /// </summary>
-        public void Clear()
-        {
-            array = EmptyArray;
-            count = 0;
-        }
-
-        /// <summary>
-        /// Determines whether this collection contains the given item.
-        /// </summary>
-        /// <param name="item">The item to find.</param>
-        /// <returns><c>true</c> if this collection contains the given item; <c>false</c> otherwise.</returns>
-        public bool Contains(T item)
-        {
-            return IndexOf(item) != -1;
-        }
-
-        /// <summary>
-        /// Copies this collection to the given array.
-        /// </summary>
-        /// <param name="array">The array to copy to.</param>
-        /// <param name="arrayIndex">The first index of the array to copy to.</param>
-        public void CopyTo(T[] array, int arrayIndex)
-        {
-            Array.Copy(this.array, 0, array, arrayIndex, count);
-        }
-
-        /// <summary>
-        /// Removes the specified item from the collection
-        /// </summary>
-        /// <param name="item">The item to remove.</param>
-        /// <returns><c>true</c> if the item was found and removed; <c>false</c> otherwise.</returns>
-        public bool Remove(T item)
-        {
-            int index = IndexOf(item);
-            if (index == -1)
-            {
-                return false;
-            }
-            Array.Copy(array, index + 1, array, index, count - index - 1);
-            count--;
-            array[count] = default(T);
-            return true;
-        }
-
-        /// <summary>
-        /// Gets the number of elements contained in the collection.
-        /// </summary>
-        public int Count
-        {
-            get
-            {
-                return count;
-            }
-        }
-
-        /// <summary>
-        /// Gets a value indicating whether the collection is read-only.
-        /// </summary>
-        public bool IsReadOnly
-        {
-            get
-            {
-                return false;
-            }
-        }
-
-        /// <summary>
-        /// Adds all of the specified values into this collection.
-        /// </summary>
-        /// <param name="values">The values to add to this collection.</param>
-        public void AddRange(IEnumerable<T> values)
-        {
-            ProtoPreconditions.CheckNotNull(values, "values");
-
-            // Optimization 1: If the collection we're adding is already a RepeatedField<T>,
-            // we know the values are valid.
-            var otherRepeatedField = values as RepeatedField<T>;
-            if (otherRepeatedField != null)
-            {
-                EnsureSize(count + otherRepeatedField.count);
-                Array.Copy(otherRepeatedField.array, 0, array, count, otherRepeatedField.count);
-                count += otherRepeatedField.count;
-                return;
-            }
-
-            // Optimization 2: The collection is an ICollection, so we can expand
-            // just once and ask the collection to copy itself into the array.
-            var collection = values as ICollection;
-            if (collection != null)
-            {
-                var extraCount = collection.Count;
-                // For reference types and nullable value types, we need to check that there are no nulls
-                // present. (This isn't a thread-safe approach, but we don't advertise this is thread-safe.)
-                // We expect the JITter to optimize this test to true/false, so it's effectively conditional
-                // specialization.
-                if (default(T) == null)
-                {
-                    // TODO: Measure whether iterating once to check and then letting the collection copy
-                    // itself is faster or slower than iterating and adding as we go. For large
-                    // collections this will not be great in terms of cache usage... but the optimized
-                    // copy may be significantly faster than doing it one at a time.
-                    foreach (var item in collection)
-                    {
-                        if (item == null)
-                        {
-                            throw new ArgumentException("Sequence contained null element", "values");
-                        }
-                    }
-                }
-                EnsureSize(count + extraCount);
-                collection.CopyTo(array, count);
-                count += extraCount;
-                return;
-            }
-
-            // We *could* check for ICollection<T> as well, but very very few collections implement
-            // ICollection<T> but not ICollection. (HashSet<T> does, for one...)
-
-            // Fall back to a slower path of adding items one at a time.
-            foreach (T item in values)
-            {
-                Add(item);
-            }
-        }
-
-        /// <summary>
-        /// Adds all of the specified values into this collection. This method is present to
-        /// allow repeated fields to be constructed from queries within collection initializers.
-        /// Within non-collection-initializer code, consider using the equivalent <see cref="AddRange"/>
-        /// method instead for clarity.
-        /// </summary>
-        /// <param name="values">The values to add to this collection.</param>
-        public void Add(IEnumerable<T> values)
-        {
-            AddRange(values);
-        }
-
-        /// <summary>
-        /// Returns an enumerator that iterates through the collection.
-        /// </summary>
-        /// <returns>
-        /// An enumerator that can be used to iterate through the collection.
-        /// </returns>
-        public IEnumerator<T> GetEnumerator()
-        {
-            for (int i = 0; i < count; i++)
-            {
-                yield return array[i];
-            }
-        }
-
-        /// <summary>
-        /// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
-        /// </summary>
-        /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
-        /// <returns>
-        ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
-        /// </returns>
-        public override bool Equals(object obj)
-        {
-            return Equals(obj as RepeatedField<T>);
-        }
-
-        /// <summary>
-        /// Returns an enumerator that iterates through a collection.
-        /// </summary>
-        /// <returns>
-        /// An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
-        /// </returns>
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return GetEnumerator();
-        }
-
-        /// <summary>
-        /// Returns a hash code for this instance.
-        /// </summary>
-        /// <returns>
-        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
-        /// </returns>
-        public override int GetHashCode()
-        {
-            int hash = 0;
-            for (int i = 0; i < count; i++)
-            {
-                hash = hash * 31 + array[i].GetHashCode();
-            }
-            return hash;
-        }
-
-        /// <summary>
-        /// Compares this repeated field with another for equality.
-        /// </summary>
-        /// <param name="other">The repeated field to compare this with.</param>
-        /// <returns><c>true</c> if <paramref name="other"/> refers to an equal repeated field; <c>false</c> otherwise.</returns>
-        public bool Equals(RepeatedField<T> other)
-        {
-            if (ReferenceEquals(other, null))
-            {
-                return false;
-            }
-            if (ReferenceEquals(other, this))
-            {
-                return true;
-            }
-            if (other.Count != this.Count)
-            {
-                return false;
-            }
-            EqualityComparer<T> comparer = EqualityComparer<T>.Default;
-            for (int i = 0; i < count; i++)
-            {
-                if (!comparer.Equals(array[i], other.array[i]))
-                {
-                    return false;
-                }
-            }
-            return true;
-        }
-
-        /// <summary>
-        /// Returns the index of the given item within the collection, or -1 if the item is not
-        /// present.
-        /// </summary>
-        /// <param name="item">The item to find in the collection.</param>
-        /// <returns>The zero-based index of the item, or -1 if it is not found.</returns>
-        public int IndexOf(T item)
-        {
-            ProtoPreconditions.CheckNotNullUnconstrained(item, "item");
-            EqualityComparer<T> comparer = EqualityComparer<T>.Default;
-            for (int i = 0; i < count; i++)
-            {
-                if (comparer.Equals(array[i], item))
-                {
-                    return i;
-                }
-            }
-            return -1;
-        }
-
-        /// <summary>
-        /// Inserts the given item at the specified index.
-        /// </summary>
-        /// <param name="index">The index at which to insert the item.</param>
-        /// <param name="item">The item to insert.</param>
-        public void Insert(int index, T item)
-        {
-            ProtoPreconditions.CheckNotNullUnconstrained(item, "item");
-            if (index < 0 || index > count)
-            {
-                throw new ArgumentOutOfRangeException("index");
-            }
-            EnsureSize(count + 1);
-            Array.Copy(array, index, array, index + 1, count - index);
-            array[index] = item;
-            count++;
-        }
-
-        /// <summary>
-        /// Removes the item at the given index.
-        /// </summary>
-        /// <param name="index">The zero-based index of the item to remove.</param>
-        public void RemoveAt(int index)
-        {
-            if (index < 0 || index >= count)
-            {
-                throw new ArgumentOutOfRangeException("index");
-            }
-            Array.Copy(array, index + 1, array, index, count - index - 1);
-            count--;
-            array[count] = default(T);
-        }
-
-        /// <summary>
-        /// Gets or sets the item at the specified index.
-        /// </summary>
-        /// <value>
-        /// The element at the specified index.
-        /// </value>
-        /// <param name="index">The zero-based index of the element to get or set.</param>
-        /// <returns>The item at the specified index.</returns>
-        public T this[int index]
-        {
-            get
-            {
-                if (index < 0 || index >= count)
-                {
-                    throw new ArgumentOutOfRangeException("index");
-                }
-                return array[index];
-            }
-            set
-            {
-                if (index < 0 || index >= count)
-                {
-                    throw new ArgumentOutOfRangeException("index");
-                }
-                ProtoPreconditions.CheckNotNullUnconstrained(value, "value");
-                array[index] = value;
-            }
-        }
-
-        #region Explicit interface implementation for IList and ICollection.
-        bool IList.IsFixedSize
-        {
-            get
-            {
-                return false;
-            }
-        }
-
-        void ICollection.CopyTo(Array array, int index)
-        {
-            Array.Copy(this.array, 0, array, index, count);
-        }
-
-        bool ICollection.IsSynchronized
-        {
-            get
-            {
-                return false;
-            }
-        }
-
-        object ICollection.SyncRoot
-        {
-            get
-            {
-                return this;
-            }
-        }
-
-        object IList.this[int index]
-        {
-            get { return this[index]; }
-            set { this[index] = (T)value; }
-        }
-
-        int IList.Add(object value)
-        {
-            Add((T)value);
-            return count - 1;
-        }
-
-        bool IList.Contains(object value)
-        {
-            return (value is T && Contains((T)value));
-        }
-
-        int IList.IndexOf(object value)
-        {
-            if (!(value is T))
-            {
-                return -1;
-            }
-            return IndexOf((T)value);
-        }
-
-        void IList.Insert(int index, object value)
-        {
-            Insert(index, (T)value);
-        }
-
-        void IList.Remove(object value)
-        {
-            if (!(value is T))
-            {
-                return;
-            }
-            Remove((T)value);
-        }
-        #endregion        
-    }
-}

+ 0 - 64
Server/ThirdParty/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs

@@ -1,64 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System.Reflection;
-
-namespace Google.Protobuf.Compatibility
-{
-    /// <summary>
-    /// Extension methods for <see cref="PropertyInfo"/>, effectively providing
-    /// the familiar members from previous desktop framework versions while
-    /// targeting the newer releases, .NET Core etc.
-    /// </summary>
-    internal static class PropertyInfoExtensions
-    {
-        /// <summary>
-        /// Returns the public getter of a property, or null if there is no such getter
-        /// (either because it's read-only, or the getter isn't public).
-        /// </summary>
-        internal static MethodInfo GetGetMethod(this PropertyInfo target)
-        {
-            var method = target.GetGetMethod();
-            return method != null && method.IsPublic ? method : null;
-        }
-
-        /// <summary>
-        /// Returns the public setter of a property, or null if there is no such setter
-        /// (either because it's write-only, or the setter isn't public).
-        /// </summary>
-        internal static MethodInfo GetSetMethod(this PropertyInfo target)
-        {
-            var method = target.GetSetMethod();
-            return method != null && method.IsPublic ? method : null;
-        }
-    }
-}

+ 0 - 64
Server/ThirdParty/Google.Protobuf/Compatibility/StreamExtensions.cs

@@ -1,64 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.IO;
-
-namespace Google.Protobuf.Compatibility
-{
-    /// <summary>
-    /// Extension methods for <see cref="Stream"/> in order to provide
-    /// backwards compatibility with .NET 3.5
-    /// </summary>
-    public static class StreamExtensions
-    {
-        // 81920 seems to be the default buffer size used in .NET 4.5.1
-        private const int BUFFER_SIZE = 81920;
-
-        /// <summary>
-        /// Write the contents of the current stream to the destination stream
-        /// </summary>
-        public static void CopyTo(this Stream source, Stream destination)
-        {
-            if (destination == null)
-            {
-                throw new ArgumentNullException("destination");
-            }
-
-            byte[] buffer = new byte[BUFFER_SIZE];
-            int numBytesRead;
-            while ((numBytesRead = source.Read(buffer, 0, buffer.Length)) > 0) {
-                destination.Write(buffer, 0, numBytesRead);
-            }
-        }
-    }
-}

+ 0 - 379
Server/ThirdParty/Google.Protobuf/FieldCodec.cs

@@ -1,379 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.Collections.Generic;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Factory methods for <see cref="FieldCodec{T}"/>.
-    /// </summary>
-    public static class FieldCodec
-    {
-        // TODO: Avoid the "dual hit" of lambda expressions: create open delegates instead. (At least test...)
-
-        /// <summary>
-        /// Retrieves a codec suitable for a string field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<string> ForString(uint tag)
-        {
-            return new FieldCodec<string>(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for a bytes field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<ByteString> ForBytes(uint tag)
-        {
-            return new FieldCodec<ByteString>(input => input.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for a bool field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<bool> ForBool(uint tag)
-        {
-            return new FieldCodec<bool>(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.ComputeBoolSize, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for an int32 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<int> ForInt32(uint tag)
-        {
-            return new FieldCodec<int>(input => input.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for an sint32 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<int> ForSInt32(uint tag)
-        {
-            return new FieldCodec<int>(input => input.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for a fixed32 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<uint> ForFixed32(uint tag)
-        {
-            return new FieldCodec<uint>(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for an sfixed32 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<int> ForSFixed32(uint tag)
-        {
-            return new FieldCodec<int>(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for a uint32 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<uint> ForUInt32(uint tag)
-        {
-            return new FieldCodec<uint>(input => input.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for an int64 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<long> ForInt64(uint tag)
-        {
-            return new FieldCodec<long>(input => input.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for an sint64 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<long> ForSInt64(uint tag)
-        {
-            return new FieldCodec<long>(input => input.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for a fixed64 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<ulong> ForFixed64(uint tag)
-        {
-            return new FieldCodec<ulong>(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for an sfixed64 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<long> ForSFixed64(uint tag)
-        {
-            return new FieldCodec<long>(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for a uint64 field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<ulong> ForUInt64(uint tag)
-        {
-            return new FieldCodec<ulong>(input => input.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for a float field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<float> ForFloat(uint tag)
-        {
-            return new FieldCodec<float>(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.ComputeFloatSize, tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for a double field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<double> ForDouble(uint tag)
-        {
-            return new FieldCodec<double>(input => input.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.ComputeDoubleSize, tag);
-        }
-
-        // Enums are tricky. We can probably use expression trees to build these delegates automatically,
-        // but it's easy to generate the code for it.
-
-        /// <summary>
-        /// Retrieves a codec suitable for an enum field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <param name="toInt32">A conversion function from <see cref="Int32"/> to the enum type.</param>
-        /// <param name="fromInt32">A conversion function from the enum type to <see cref="Int32"/>.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32)
-        {
-            return new FieldCodec<T>(input => fromInt32(
-                input.ReadEnum()),
-                (output, value) => output.WriteEnum(toInt32(value)),
-                value => CodedOutputStream.ComputeEnumSize(toInt32(value)), tag);
-        }
-
-        /// <summary>
-        /// Retrieves a codec suitable for a message field with the given tag.
-        /// </summary>
-        /// <param name="tag">The tag.</param>
-        /// <param name="parser">A parser to use for the message type.</param>
-        /// <returns>A codec for the given tag.</returns>
-        public static FieldCodec<T> ForMessage<T>(uint tag, MessageParser<T> parser) where T : IMessage
-        {
-            return new FieldCodec<T>(input => { T message = parser.CreateTemplate(); input.ReadMessage(message); return message; },
-                (output, value) => output.WriteMessage(value), message => CodedOutputStream.ComputeMessageSize(message), tag);
-        }
-    }
-
-    /// <summary>
-    /// <para>
-    /// An encode/decode pair for a single field. This effectively encapsulates
-    /// all the information needed to read or write the field value from/to a coded
-    /// stream.
-    /// </para>
-    /// <para>
-    /// This class is public and has to be as it is used by generated code, but its public
-    /// API is very limited - just what the generated code needs to call directly.
-    /// </para>
-    /// </summary>
-    /// <remarks>
-    /// This never writes default values to the stream, and does not address "packedness"
-    /// in repeated fields itself, other than to know whether or not the field *should* be packed.
-    /// </remarks>
-    public sealed class FieldCodec<T>
-    {
-        private static readonly T DefaultDefault;
-        // Only non-nullable value types support packing. This is the simplest way of detecting that.
-        private static readonly bool TypeSupportsPacking = default(T) != null;
-
-        static FieldCodec()
-        {
-            if (typeof(T) == typeof(string))
-            {
-                DefaultDefault = (T)(object)"";
-            }
-            else if (typeof(T) == typeof(ByteString))
-            {
-                DefaultDefault = (T)(object)ByteString.Empty;
-            }
-            // Otherwise it's the default value of the CLR type
-        }
-
-        internal static bool IsPackedRepeatedField(uint tag)
-        {
-            return TypeSupportsPacking && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited;
-        }
-
-        internal readonly bool PackedRepeatedField;
-
-        /// <summary>
-        /// Returns a delegate to write a value (unconditionally) to a coded output stream.
-        /// </summary>
-        internal readonly Action<CodedOutputStream, T> ValueWriter;
-
-        /// <summary>
-        /// Returns the size calculator for just a value.
-        /// </summary>
-        internal readonly Func<T, int> ValueSizeCalculator;
-
-        /// <summary>
-        /// Returns a delegate to read a value from a coded input stream. It is assumed that
-        /// the stream is already positioned on the appropriate tag.
-        /// </summary>
-        internal readonly Func<CodedInputStream, T> ValueReader;
-
-        /// <summary>
-        /// Returns the fixed size for an entry, or 0 if sizes vary.
-        /// </summary>
-        internal readonly int FixedSize;
-
-        /// <summary>
-        /// Gets the tag of the codec.
-        /// </summary>
-        /// <value>
-        /// The tag of the codec.
-        /// </value>
-        internal readonly uint Tag;
-
-        /// <summary>
-        /// Default value for this codec. Usually the same for every instance of the same type, but
-        /// for string/ByteString wrapper fields the codec's default value is null, whereas for
-        /// other string/ByteString fields it's "" or ByteString.Empty.
-        /// </summary>
-        /// <value>
-        /// The default value of the codec's type.
-        /// </value>
-        internal readonly T DefaultValue;
-
-        private readonly int tagSize;
-        
-        internal FieldCodec(
-                Func<CodedInputStream, T> reader,
-                Action<CodedOutputStream, T> writer,
-                int fixedSize,
-                uint tag) : this(reader, writer, _ => fixedSize, tag)
-        {
-            FixedSize = fixedSize;
-        }
-
-        internal FieldCodec(
-            Func<CodedInputStream, T> reader,
-            Action<CodedOutputStream, T> writer,
-            Func<T, int> sizeCalculator,
-            uint tag) : this(reader, writer, sizeCalculator, tag, DefaultDefault)
-        {
-        }
-
-        internal FieldCodec(
-            Func<CodedInputStream, T> reader,
-            Action<CodedOutputStream, T> writer,
-            Func<T, int> sizeCalculator,
-            uint tag,
-            T defaultValue)
-        {
-            ValueReader = reader;
-            ValueWriter = writer;
-            ValueSizeCalculator = sizeCalculator;
-            FixedSize = 0;
-            Tag = tag;
-            DefaultValue = defaultValue;
-            tagSize = CodedOutputStream.ComputeRawVarint32Size(tag);
-            // Detect packed-ness once, so we can check for it within RepeatedField<T>.
-            PackedRepeatedField = IsPackedRepeatedField(tag);
-        }
-
-        /// <summary>
-        /// Write a tag and the given value, *if* the value is not the default.
-        /// </summary>
-        public void WriteTagAndValue(CodedOutputStream output, T value)
-        {
-            if (!IsDefault(value))
-            {
-                output.WriteTag(Tag);
-                ValueWriter(output, value);
-            }
-        }
-
-        /// <summary>
-        /// Reads a value of the codec type from the given <see cref="CodedInputStream"/>.
-        /// </summary>
-        /// <param name="input">The input stream to read from.</param>
-        /// <returns>The value read from the stream.</returns>
-        public T Read(CodedInputStream input)
-        {
-            return ValueReader(input);
-        }
-
-        /// <summary>
-        /// Calculates the size required to write the given value, with a tag,
-        /// if the value is not the default.
-        /// </summary>
-        public int CalculateSizeWithTag(T value)
-        {
-            return IsDefault(value) ? 0 : ValueSizeCalculator(value) + tagSize;
-        }
-
-        private bool IsDefault(T value)
-        {
-            return EqualityComparer<T>.Default.Equals(value, DefaultValue);
-        }
-    }
-}

+ 23 - 0
Server/ThirdParty/Google.Protobuf/Google.Protobuf.csproj

@@ -5,7 +5,30 @@
     <ApplicationIcon />
     <StartupObject />
   </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\ByteArray.cs" Link="ByteArray.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\ByteString.cs" Link="ByteString.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\CodedInputStream.cs" Link="CodedInputStream.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\CodedOutputStream.ComputeSize.cs" Link="CodedOutputStream.ComputeSize.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\CodedOutputStream.cs" Link="CodedOutputStream.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\Collections\RepeatedField.cs" Link="Collections\RepeatedField.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\Compatibility\PropertyInfoExtensions.cs" Link="Compatibility\PropertyInfoExtensions.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\Compatibility\StreamExtensions.cs" Link="Compatibility\StreamExtensions.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\FieldCodec.cs" Link="FieldCodec.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\ICustomDiagnosticMessage.cs" Link="ICustomDiagnosticMessage.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\IMessage.cs" Link="IMessage.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\InvalidProtocolBufferException.cs" Link="InvalidProtocolBufferException.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\LimitedInputStream.cs" Link="LimitedInputStream.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\MessageExtensions.cs" Link="MessageExtensions.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\MessageParser.cs" Link="MessageParser.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\ProtoPreconditions.cs" Link="ProtoPreconditions.cs" />
+    <Compile Include="..\..\..\Unity\Assets\ThirdParty\Google.Protobuf\WireFormat.cs" Link="WireFormat.cs" />
+  </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\MongodbDriver\DotNetCoreDriver\MongoDB.Bson\MongoDB.Bson.csproj" />
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Collections\" />
+    <Folder Include="Compatibility\" />
+  </ItemGroup>
 </Project>

+ 0 - 69
Server/ThirdParty/Google.Protobuf/ICustomDiagnosticMessage.cs

@@ -1,69 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2016 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// A message type that has a custom string format for diagnostic purposes.
-    /// </summary>
-    /// <remarks>
-    /// <para>
-    /// Calling <see cref="object.ToString"/> on a generated message type normally
-    /// returns the JSON representation. If a message type implements this interface,
-    /// then the <see cref="ToDiagnosticString"/> method will be called instead of the regular
-    /// JSON formatting code, but only when <c>ToString()</c> is called either on the message itself
-    /// or on another message which contains it. This does not affect the normal JSON formatting of
-    /// the message.
-    /// </para>
-    /// <para>
-    /// For example, if you create a proto message representing a GUID, the internal
-    /// representation may be a <c>bytes</c> field or four <c>fixed32</c> fields. However, when debugging
-    /// it may be more convenient to see a result in the same format as <see cref="System.Guid"/> provides.
-    /// </para>
-    /// <para>This interface extends <see cref="IMessage"/> to avoid it accidentally being implemented
-    /// on types other than messages, where it would not be used by anything in the framework.</para>
-    /// </remarks>
-    public interface ICustomDiagnosticMessage : IMessage
-    {
-        /// <summary>
-        /// Returns a string representation of this object, for diagnostic purposes.
-        /// </summary>
-        /// <remarks>
-        /// This method is called when a message is formatted as part of a <see cref="object.ToString"/>
-        /// call. It does not affect the JSON representation used by <see cref="JsonFormatter"/> other than
-        /// in calls to <see cref="JsonFormatter.ToDiagnosticString(IMessage)"/>. While it is recommended
-        /// that the result is valid JSON, this is never assumed by the Protobuf library.
-        /// </remarks>
-        /// <returns>A string representation of this object, for diagnostic purposes.</returns>
-        string ToDiagnosticString();
-    }
-}

+ 0 - 64
Server/ThirdParty/Google.Protobuf/IMessage.cs

@@ -1,64 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Interface for a Protocol Buffers message, supporting
-    /// basic operations required for serialization.
-    /// </summary>
-    public interface IMessage
-    {
-        /// <summary>
-        /// Merges the data from the specified coded input stream with the current message.
-        /// </summary>
-        /// <remarks>See the user guide for precise merge semantics.</remarks>
-        /// <param name="input"></param>
-        void MergeFrom(CodedInputStream input);
-
-        /// <summary>
-        /// Writes the data to the given coded output stream.
-        /// </summary>
-        /// <param name="output">Coded output stream to write the data to. Must not be null.</param>
-        void WriteTo(CodedOutputStream output);
-
-        /// <summary>
-        /// Calculates the size of this message in Protocol Buffer wire format, in bytes.
-        /// </summary>
-        /// <returns>The number of bytes required to write this message
-        /// to a coded output stream.</returns>
-        int CalculateSize();
-
-    }
-
-}

+ 0 - 129
Server/ThirdParty/Google.Protobuf/InvalidProtocolBufferException.cs

@@ -1,129 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-using System.IO;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Thrown when a protocol message being parsed is invalid in some way,
-    /// e.g. it contains a malformed varint or a negative byte length.
-    /// </summary>
-    public sealed class InvalidProtocolBufferException : IOException
-    {
-        internal InvalidProtocolBufferException(string message)
-            : base(message)
-        {
-        }
-
-        internal InvalidProtocolBufferException(string message, Exception innerException)
-            : base(message, innerException)
-        {
-        }
-
-        internal static InvalidProtocolBufferException MoreDataAvailable()
-        {
-            return new InvalidProtocolBufferException(
-                "Completed reading a message while more data was available in the stream.");
-        }
-
-        internal static InvalidProtocolBufferException TruncatedMessage()
-        {
-            return new InvalidProtocolBufferException(
-                "While parsing a protocol message, the input ended unexpectedly " +
-                "in the middle of a field.  This could mean either that the " +
-                "input has been truncated or that an embedded message " +
-                "misreported its own length.");
-        }
-
-        internal static InvalidProtocolBufferException NegativeSize()
-        {
-            return new InvalidProtocolBufferException(
-                "CodedInputStream encountered an embedded string or message " +
-                "which claimed to have negative size.");
-        }
-
-        internal static InvalidProtocolBufferException MalformedVarint()
-        {
-            return new InvalidProtocolBufferException(
-                "CodedInputStream encountered a malformed varint.");
-        }
-
-        /// <summary>
-        /// Creates an exception for an error condition of an invalid tag being encountered.
-        /// </summary>
-        internal static InvalidProtocolBufferException InvalidTag()
-        {
-            return new InvalidProtocolBufferException(
-                "Protocol message contained an invalid tag (zero).");
-        }
-
-        internal static InvalidProtocolBufferException InvalidBase64(Exception innerException)
-        {
-            return new InvalidProtocolBufferException("Invalid base64 data", innerException);
-        }
-
-        internal static InvalidProtocolBufferException InvalidEndTag()
-        {
-            return new InvalidProtocolBufferException(
-                "Protocol message end-group tag did not match expected tag.");
-        }
-
-        internal static InvalidProtocolBufferException RecursionLimitExceeded()
-        {
-            return new InvalidProtocolBufferException(
-                "Protocol message had too many levels of nesting.  May be malicious.  " +
-                "Use CodedInputStream.SetRecursionLimit() to increase the depth limit.");
-        }
-
-        internal static InvalidProtocolBufferException JsonRecursionLimitExceeded()
-        {
-            return new InvalidProtocolBufferException(
-                "Protocol message had too many levels of nesting.  May be malicious.  " +
-                "Use JsonParser.Settings to increase the depth limit.");
-        }
-
-        internal static InvalidProtocolBufferException SizeLimitExceeded()
-        {
-            return new InvalidProtocolBufferException(
-                "Protocol message was too large.  May be malicious.  " +
-                "Use CodedInputStream.SetSizeLimit() to increase the size limit.");
-        }
-
-        internal static InvalidProtocolBufferException InvalidMessageStreamTag()
-        {
-            return new InvalidProtocolBufferException(
-                "Stream of protocol messages had invalid tag. Expected tag is length-delimited field 1.");
-        }
-    }
-}

+ 0 - 110
Server/ThirdParty/Google.Protobuf/LimitedInputStream.cs

@@ -1,110 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-    
-using System;
-using System.IO;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Stream implementation which proxies another stream, only allowing a certain amount
-    /// of data to be read. Note that this is only used to read delimited streams, so it
-    /// doesn't attempt to implement everything.
-    /// </summary>
-    internal sealed class LimitedInputStream : Stream
-    {
-        private readonly Stream proxied;
-        private int bytesLeft;
-
-        internal LimitedInputStream(Stream proxied, int size)
-        {
-            this.proxied = proxied;
-            bytesLeft = size;
-        }
-
-        public override bool CanRead
-        {
-            get { return true; }
-        }
-
-        public override bool CanSeek
-        {
-            get { return false; }
-        }
-
-        public override bool CanWrite
-        {
-            get { return false; }
-        }
-
-        public override void Flush()
-        {
-        }
-
-        public override long Length
-        {
-            get { throw new NotSupportedException(); }
-        }
-
-        public override long Position
-        {
-            get { throw new NotSupportedException(); }
-            set { throw new NotSupportedException(); }
-        }
-
-        public override int Read(byte[] buffer, int offset, int count)
-        {
-            if (bytesLeft > 0)
-            {
-                int bytesRead = proxied.Read(buffer, offset, Math.Min(bytesLeft, count));
-                bytesLeft -= bytesRead;
-                return bytesRead;
-            }
-            return 0;
-        }
-
-        public override long Seek(long offset, SeekOrigin origin)
-        {
-            throw new NotSupportedException();
-        }
-
-        public override void SetLength(long value)
-        {
-            throw new NotSupportedException();
-        }
-
-        public override void Write(byte[] buffer, int offset, int count)
-        {
-            throw new NotSupportedException();
-        }
-    }
-}

+ 0 - 171
Server/ThirdParty/Google.Protobuf/MessageExtensions.cs

@@ -1,171 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System.IO;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Extension methods on <see cref="IMessage"/> and <see cref="IMessage{T}"/>.
-    /// </summary>
-    public static class MessageExtensions
-    {
-        /// <summary>
-        /// Merges data from the given byte array into an existing message.
-        /// </summary>
-        /// <param name="message">The message to merge the data into.</param>
-        /// <param name="data">The data to merge, which must be protobuf-encoded binary data.</param>
-        public static void MergeFrom(this IMessage message, byte[] data)
-        {
-            ProtoPreconditions.CheckNotNull(message, "message");
-            ProtoPreconditions.CheckNotNull(data, "data");
-            CodedInputStream input = new CodedInputStream(data);
-            message.MergeFrom(input);
-            input.CheckReadEndOfStreamTag();
-        }
-
-	    /// <summary>
-	    /// Merges data from the given byte array into an existing message.
-	    /// </summary>
-	    /// <param name="message">The message to merge the data into.</param>
-	    /// <param name="data">The data to merge, which must be protobuf-encoded binary data.</param>
-	    public static void MergeFrom(this IMessage message, byte[] data, int offset, int length)
-	    {
-		    ProtoPreconditions.CheckNotNull(message, "message");
-		    ProtoPreconditions.CheckNotNull(data, "data");
-		    CodedInputStream input = new CodedInputStream(data, offset, length);
-		    message.MergeFrom(input);
-		    input.CheckReadEndOfStreamTag();
-	    }
-
-		/// <summary>
-		/// Merges data from the given byte string into an existing message.
-		/// </summary>
-		/// <param name="message">The message to merge the data into.</param>
-		/// <param name="data">The data to merge, which must be protobuf-encoded binary data.</param>
-		public static void MergeFrom(this IMessage message, ByteString data)
-        {
-            ProtoPreconditions.CheckNotNull(message, "message");
-            ProtoPreconditions.CheckNotNull(data, "data");
-            CodedInputStream input = data.CreateCodedInput();
-            message.MergeFrom(input);
-            input.CheckReadEndOfStreamTag();
-        }
-
-        /// <summary>
-        /// Merges data from the given stream into an existing message.
-        /// </summary>
-        /// <param name="message">The message to merge the data into.</param>
-        /// <param name="input">Stream containing the data to merge, which must be protobuf-encoded binary data.</param>
-        public static void MergeFrom(this IMessage message, Stream input)
-        {
-            ProtoPreconditions.CheckNotNull(message, "message");
-            ProtoPreconditions.CheckNotNull(input, "input");
-            CodedInputStream codedInput = new CodedInputStream(input);
-            message.MergeFrom(codedInput);
-            codedInput.CheckReadEndOfStreamTag();
-        }
-
-        /// <summary>
-        /// Merges length-delimited data from the given stream into an existing message.
-        /// </summary>
-        /// <remarks>
-        /// The stream is expected to contain a length and then the data. Only the amount of data
-        /// specified by the length will be consumed.
-        /// </remarks>
-        /// <param name="message">The message to merge the data into.</param>
-        /// <param name="input">Stream containing the data to merge, which must be protobuf-encoded binary data.</param>
-        public static void MergeDelimitedFrom(this IMessage message, Stream input)
-        {
-            ProtoPreconditions.CheckNotNull(message, "message");
-            ProtoPreconditions.CheckNotNull(input, "input");
-            int size = (int) CodedInputStream.ReadRawVarint32(input);
-            Stream limitedStream = new LimitedInputStream(input, size);
-            message.MergeFrom(limitedStream);
-        }
-
-        /// <summary>
-        /// Converts the given message into a byte array in protobuf encoding.
-        /// </summary>
-        /// <param name="message">The message to convert.</param>
-        /// <returns>The message data as a byte array.</returns>
-        public static byte[] ToByteArray(this IMessage message)
-        {
-            ProtoPreconditions.CheckNotNull(message, "message");
-            byte[] result = new byte[message.CalculateSize()];
-            CodedOutputStream output = new CodedOutputStream(result);
-            message.WriteTo(output);
-            output.CheckNoSpaceLeft();
-            return result;
-        }
-
-        /// <summary>
-        /// Writes the given message data to the given stream in protobuf encoding.
-        /// </summary>
-        /// <param name="message">The message to write to the stream.</param>
-        /// <param name="output">The stream to write to.</param>
-        public static void WriteTo(this IMessage message, Stream output)
-        {
-            ProtoPreconditions.CheckNotNull(message, "message");
-            ProtoPreconditions.CheckNotNull(output, "output");
-            CodedOutputStream codedOutput = new CodedOutputStream(output);
-            message.WriteTo(codedOutput);
-            codedOutput.Flush();
-        }
-
-        /// <summary>
-        /// Writes the length and then data of the given message to a stream.
-        /// </summary>
-        /// <param name="message">The message to write.</param>
-        /// <param name="output">The output stream to write to.</param>
-        public static void WriteDelimitedTo(this IMessage message, Stream output)
-        {
-            ProtoPreconditions.CheckNotNull(message, "message");
-            ProtoPreconditions.CheckNotNull(output, "output");
-            CodedOutputStream codedOutput = new CodedOutputStream(output);
-            codedOutput.WriteRawVarint32((uint)message.CalculateSize());
-            message.WriteTo(codedOutput);
-            codedOutput.Flush();
-        }
-
-        /// <summary>
-        /// Converts the given message into a byte string in protobuf encoding.
-        /// </summary>
-        /// <param name="message">The message to convert.</param>
-        /// <returns>The message data as a byte string.</returns>
-        public static ByteString ToByteString(this IMessage message)
-        {
-            ProtoPreconditions.CheckNotNull(message, "message");
-            return ByteString.AttachBytes(message.ToByteArray());
-        }        
-    }
-}

+ 0 - 241
Server/ThirdParty/Google.Protobuf/MessageParser.cs

@@ -1,241 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2015 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-    
-using System;
-using System.IO;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// A general message parser, typically used by reflection-based code as all the methods
-    /// return simple <see cref="IMessage"/>.
-    /// </summary>
-    public class MessageParser
-    {
-        private Func<IMessage> factory;
-
-        internal MessageParser(Func<IMessage> factory)
-        {
-            this.factory = factory;
-        }
-
-        /// <summary>
-        /// Creates a template instance ready for population.
-        /// </summary>
-        /// <returns>An empty message.</returns>
-        internal IMessage CreateTemplate()
-        {
-            return factory();
-        }
-
-        /// <summary>
-        /// Parses a message from a byte array.
-        /// </summary>
-        /// <param name="data">The byte array containing the message. Must not be null.</param>
-        /// <returns>The newly parsed message.</returns>
-        public IMessage ParseFrom(byte[] data)
-        {
-            ProtoPreconditions.CheckNotNull(data, "data");
-            IMessage message = factory();
-            message.MergeFrom(data);
-            return message;
-        }
-
-        /// <summary>
-        /// Parses a message from the given byte string.
-        /// </summary>
-        /// <param name="data">The data to parse.</param>
-        /// <returns>The parsed message.</returns>
-        public IMessage ParseFrom(ByteString data)
-        {
-            ProtoPreconditions.CheckNotNull(data, "data");
-            IMessage message = factory();
-            message.MergeFrom(data);
-            return message;
-        }
-
-        /// <summary>
-        /// Parses a message from the given stream.
-        /// </summary>
-        /// <param name="input">The stream to parse.</param>
-        /// <returns>The parsed message.</returns>
-        public IMessage ParseFrom(Stream input)
-        {
-            IMessage message = factory();
-            message.MergeFrom(input);
-            return message;
-        }
-
-        /// <summary>
-        /// Parses a length-delimited message from the given stream.
-        /// </summary>
-        /// <remarks>
-        /// The stream is expected to contain a length and then the data. Only the amount of data
-        /// specified by the length will be consumed.
-        /// </remarks>
-        /// <param name="input">The stream to parse.</param>
-        /// <returns>The parsed message.</returns>
-        public IMessage ParseDelimitedFrom(Stream input)
-        {
-            IMessage message = factory();
-            message.MergeDelimitedFrom(input);
-            return message;
-        }
-
-        /// <summary>
-        /// Parses a message from the given coded input stream.
-        /// </summary>
-        /// <param name="input">The stream to parse.</param>
-        /// <returns>The parsed message.</returns>
-        public IMessage ParseFrom(CodedInputStream input)
-        {
-            IMessage message = factory();
-            message.MergeFrom(input);
-            return message;
-        }
-
-    }
-
-    /// <summary>
-    /// A parser for a specific message type.
-    /// </summary>
-    /// <remarks>
-    /// <p>
-    /// This delegates most behavior to the
-    /// <see cref="IMessage.MergeFrom"/> implementation within the original type, but
-    /// provides convenient overloads to parse from a variety of sources.
-    /// </p>
-    /// <p>
-    /// Most applications will never need to create their own instances of this type;
-    /// instead, use the static <c>Parser</c> property of a generated message type to obtain a
-    /// parser for that type.
-    /// </p>
-    /// </remarks>
-    /// <typeparam name="T">The type of message to be parsed.</typeparam>
-    public sealed class MessageParser<T> : MessageParser where T : IMessage
-    {
-        // Implementation note: all the methods here *could* just delegate up to the base class and cast the result.
-        // The current implementation avoids a virtual method call and a cast, which *may* be significant in some cases.
-        // Benchmarking work is required to measure the significance - but it's only a few lines of code in any case.
-        // The API wouldn't change anyway - just the implementation - so this work can be deferred.
-        private readonly Func<T> factory; 
-
-        /// <summary>
-        /// Creates a new parser.
-        /// </summary>
-        /// <remarks>
-        /// The factory method is effectively an optimization over using a generic constraint
-        /// to require a parameterless constructor: delegates are significantly faster to execute.
-        /// </remarks>
-        /// <param name="factory">Function to invoke when a new, empty message is required.</param>
-        public MessageParser(Func<T> factory) : base(() => factory())
-        {
-            this.factory = factory;
-        }
-
-        /// <summary>
-        /// Creates a template instance ready for population.
-        /// </summary>
-        /// <returns>An empty message.</returns>
-        internal new T CreateTemplate()
-        {
-            return factory();
-        }
-
-        /// <summary>
-        /// Parses a message from a byte array.
-        /// </summary>
-        /// <param name="data">The byte array containing the message. Must not be null.</param>
-        /// <returns>The newly parsed message.</returns>
-        public new T ParseFrom(byte[] data)
-        {
-            ProtoPreconditions.CheckNotNull(data, "data");
-            T message = factory();
-            message.MergeFrom(data);
-            return message;
-        }
-
-        /// <summary>
-        /// Parses a message from the given byte string.
-        /// </summary>
-        /// <param name="data">The data to parse.</param>
-        /// <returns>The parsed message.</returns>
-        public new T ParseFrom(ByteString data)
-        {
-            ProtoPreconditions.CheckNotNull(data, "data");
-            T message = factory();
-            message.MergeFrom(data);
-            return message;
-        }
-
-        /// <summary>
-        /// Parses a message from the given stream.
-        /// </summary>
-        /// <param name="input">The stream to parse.</param>
-        /// <returns>The parsed message.</returns>
-        public new T ParseFrom(Stream input)
-        {
-            T message = factory();
-            message.MergeFrom(input);
-            return message;
-        }
-
-        /// <summary>
-        /// Parses a length-delimited message from the given stream.
-        /// </summary>
-        /// <remarks>
-        /// The stream is expected to contain a length and then the data. Only the amount of data
-        /// specified by the length will be consumed.
-        /// </remarks>
-        /// <param name="input">The stream to parse.</param>
-        /// <returns>The parsed message.</returns>
-        public new T ParseDelimitedFrom(Stream input)
-        {
-            T message = factory();
-            message.MergeDelimitedFrom(input);
-            return message;
-        }
-
-        /// <summary>
-        /// Parses a message from the given coded input stream.
-        /// </summary>
-        /// <param name="input">The stream to parse.</param>
-        /// <returns>The parsed message.</returns>
-        public new T ParseFrom(CodedInputStream input)
-        {
-            T message = factory();
-            message.MergeFrom(input);
-            return message;
-        }
-
-    }
-}

+ 0 - 12
Server/ThirdParty/Google.Protobuf/Program.cs

@@ -1,12 +0,0 @@
-using System;
-
-namespace Google.Protobuf
-{
-    class Program
-    {
-        static void Main(string[] args)
-        {
-            Console.WriteLine("Hello World!");
-        }
-    }
-}

+ 0 - 79
Server/ThirdParty/Google.Protobuf/ProtoPreconditions.cs

@@ -1,79 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-using System;
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// Helper methods for throwing exceptions when preconditions are not met.
-    /// </summary>
-    /// <remarks>
-    /// This class is used internally and by generated code; it is not particularly
-    /// expected to be used from application code, although nothing prevents it
-    /// from being used that way.
-    /// </remarks>
-    public static class ProtoPreconditions
-    {
-        /// <summary>
-        /// Throws an ArgumentNullException if the given value is null, otherwise
-        /// return the value to the caller.
-        /// </summary>
-        public static T CheckNotNull<T>(T value, string name) where T : class
-        {
-            if (value == null)
-            {
-                throw new ArgumentNullException(name);
-            }
-            return value;
-        }
-
-        /// <summary>
-        /// Throws an ArgumentNullException if the given value is null, otherwise
-        /// return the value to the caller.
-        /// </summary>
-        /// <remarks>
-        /// This is equivalent to <see cref="CheckNotNull{T}(T, string)"/> but without the type parameter
-        /// constraint. In most cases, the constraint is useful to prevent you from calling CheckNotNull
-        /// with a value type - but it gets in the way if either you want to use it with a nullable
-        /// value type, or you want to use it with an unconstrained type parameter.
-        /// </remarks>
-        internal static T CheckNotNullUnconstrained<T>(T value, string name)
-        {
-            if (value == null)
-            {
-                throw new ArgumentNullException(name);
-            }
-            return value;
-        }
-    }
-}

+ 0 - 104
Server/ThirdParty/Google.Protobuf/WireFormat.cs

@@ -1,104 +0,0 @@
-#region Copyright notice and license
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc.  All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
-
-namespace Google.Protobuf
-{
-    /// <summary>
-    /// This class is used internally by the Protocol Buffer Library and generated
-    /// message implementations. It is public only for the sake of those generated
-    /// messages. Others should not use this class directly.
-    /// <para>
-    /// This class contains constants and helper functions useful for dealing with
-    /// the Protocol Buffer wire format.
-    /// </para>
-    /// </summary>
-    public static class WireFormat
-    {
-        /// <summary>
-        /// Wire types within protobuf encoding.
-        /// </summary>
-        public enum WireType : uint
-        {
-            /// <summary>
-            /// Variable-length integer.
-            /// </summary>
-            Varint = 0,
-            /// <summary>
-            /// A fixed-length 64-bit value.
-            /// </summary>
-            Fixed64 = 1,
-            /// <summary>
-            /// A length-delimited value, i.e. a length followed by that many bytes of data.
-            /// </summary>
-            LengthDelimited = 2,
-            /// <summary>
-            /// A "start group" value - not supported by this implementation.
-            /// </summary>
-            StartGroup = 3,
-            /// <summary>
-            /// An "end group" value - not supported by this implementation.
-            /// </summary>
-            EndGroup = 4,
-            /// <summary>
-            /// A fixed-length 32-bit value.
-            /// </summary>
-            Fixed32 = 5
-        }
-        
-        private const int TagTypeBits = 3;
-        private const uint TagTypeMask = (1 << TagTypeBits) - 1;
-
-        /// <summary>
-        /// Given a tag value, determines the wire type (lower 3 bits).
-        /// </summary>
-        public static WireType GetTagWireType(uint tag)
-        {
-            return (WireType) (tag & TagTypeMask);
-        }
-
-        /// <summary>
-        /// Given a tag value, determines the field number (the upper 29 bits).
-        /// </summary>
-        public static int GetTagFieldNumber(uint tag)
-        {
-            return (int) tag >> TagTypeBits;
-        }
-
-        /// <summary>
-        /// Makes a tag value given a field number and wire type.
-        /// </summary>
-        public static uint MakeTag(int fieldNumber, WireType wireType)
-        {
-            return (uint) (fieldNumber << TagTypeBits) | (uint) wireType;
-        }        
-    }
-}