NetSerializer.Primitives.ReadVarint64 C# (CSharp) Méthode

ReadVarint64() static private méthode

static private ReadVarint64 ( Stream stream ) : ulong
stream Stream
Résultat ulong
        static ulong ReadVarint64(Stream stream)
        {
            long result = 0;
            int offset = 0;

            for (; offset < 64; offset += 7)
            {
                int b = stream.ReadByte();
                if (b == -1)
                    throw new EndOfStreamException();

                result |= ((long)(b & 0x7f)) << offset;

                if ((b & 0x80) == 0)
                    return (ulong)result;
            }

            throw new InvalidDataException();
        }