WriteUInt64Variant() private static method

private static WriteUInt64Variant ( ulong value, ProtoWriter writer ) : void
value ulong
writer ProtoWriter
return void
示例#1
0
        // Token: 0x06000158 RID: 344 RVA: 0x0000D86C File Offset: 0x0000BA6C
        public static void WriteUInt64(ulong value, ProtoWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            WireType wireType = writer.wireType;

            if (wireType == WireType.Variant)
            {
                ProtoWriter.WriteUInt64Variant(value, writer);
                writer.wireType = WireType.None;
                return;
            }
            if (wireType == WireType.Fixed64)
            {
                ProtoWriter.WriteInt64((long)value, writer);
                return;
            }
            if (wireType != WireType.Fixed32)
            {
                throw ProtoWriter.CreateException(writer);
            }
            ProtoWriter.WriteUInt32(checked ((uint)value), writer);
        }
示例#2
0
        public static void WriteUInt64(ulong value, ProtoWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            switch (writer.wireType)
            {
            case WireType.Variant:
                ProtoWriter.WriteUInt64Variant(value, writer);
                writer.wireType = WireType.None;
                return;

            case WireType.Fixed64:
                ProtoWriter.WriteInt64((long)value, writer);
                return;

            case WireType.Fixed32:
                ProtoWriter.WriteUInt32(checked ((uint)value), writer);
                return;
            }
            throw ProtoWriter.CreateException(writer);
        }
        public static void WriteInt64(long value, ProtoWriter writer)
        {
            byte[] numArray;
            int    num;

            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            ProtoBuf.WireType wireType = writer.wireType;
            switch (wireType)
            {
            case ProtoBuf.WireType.Variant:
            {
                if (value >= (long)0)
                {
                    ProtoWriter.WriteUInt64Variant((ulong)value, writer);
                    writer.wireType = ProtoBuf.WireType.None;
                    return;
                }
                ProtoWriter.DemandSpace(10, writer);
                numArray          = writer.ioBuffer;
                num               = writer.ioIndex;
                numArray[num]     = (byte)(value | (long)128);
                numArray[num + 1] = (byte)((int)(value >> 7) | 128);
                numArray[num + 2] = (byte)((int)(value >> 14) | 128);
                numArray[num + 3] = (byte)((int)(value >> 21) | 128);
                numArray[num + 4] = (byte)((int)(value >> 28) | 128);
                numArray[num + 5] = (byte)((int)(value >> 35) | 128);
                numArray[num + 6] = (byte)((int)(value >> 42) | 128);
                numArray[num + 7] = (byte)((int)(value >> 49) | 128);
                numArray[num + 8] = (byte)((int)(value >> 56) | 128);
                numArray[num + 9] = 1;
                ProtoWriter.IncrementedAndReset(10, writer);
                return;
            }

            case ProtoBuf.WireType.Fixed64:
            {
                ProtoWriter.DemandSpace(8, writer);
                numArray          = writer.ioBuffer;
                num               = writer.ioIndex;
                numArray[num]     = (byte)value;
                numArray[num + 1] = (byte)(value >> 8);
                numArray[num + 2] = (byte)(value >> 16);
                numArray[num + 3] = (byte)(value >> 24);
                numArray[num + 4] = (byte)(value >> 32);
                numArray[num + 5] = (byte)(value >> 40);
                numArray[num + 6] = (byte)(value >> 48);
                numArray[num + 7] = (byte)(value >> 56);
                ProtoWriter.IncrementedAndReset(8, writer);
                return;
            }

            default:
            {
                if (wireType == ProtoBuf.WireType.Fixed32)
                {
                    break;
                }
                else
                {
                    if (wireType != ProtoBuf.WireType.SignedVariant)
                    {
                        throw ProtoWriter.CreateException(writer);
                    }
                    ProtoWriter.WriteUInt64Variant(ProtoWriter.Zig(value), writer);
                    writer.wireType = ProtoBuf.WireType.None;
                    return;
                }
            }
            }
            ProtoWriter.WriteInt32(checked ((int)value), writer);
        }
示例#4
0
        public static void WriteInt64(long value, ProtoWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            WireType wireType = writer.wireType;

            switch (wireType)
            {
            case WireType.Variant:
                if (value >= 0L)
                {
                    ProtoWriter.WriteUInt64Variant((ulong)value, writer);
                    writer.wireType = WireType.None;
                }
                else
                {
                    ProtoWriter.DemandSpace(10, writer);
                    byte[] array = writer.ioBuffer;
                    int    num   = writer.ioIndex;
                    array[num]     = (byte)(value | 128L);
                    array[num + 1] = (byte)((int)(value >> 7) | 128);
                    array[num + 2] = (byte)((int)(value >> 14) | 128);
                    array[num + 3] = (byte)((int)(value >> 21) | 128);
                    array[num + 4] = (byte)((int)(value >> 28) | 128);
                    array[num + 5] = (byte)((int)(value >> 35) | 128);
                    array[num + 6] = (byte)((int)(value >> 42) | 128);
                    array[num + 7] = (byte)((int)(value >> 49) | 128);
                    array[num + 8] = (byte)((int)(value >> 56) | 128);
                    array[num + 9] = 1;
                    ProtoWriter.IncrementedAndReset(10, writer);
                }
                return;

            case WireType.Fixed64:
            {
                ProtoWriter.DemandSpace(8, writer);
                byte[] array = writer.ioBuffer;
                int    num   = writer.ioIndex;
                array[num]     = (byte)value;
                array[num + 1] = (byte)(value >> 8);
                array[num + 2] = (byte)(value >> 16);
                array[num + 3] = (byte)(value >> 24);
                array[num + 4] = (byte)(value >> 32);
                array[num + 5] = (byte)(value >> 40);
                array[num + 6] = (byte)(value >> 48);
                array[num + 7] = (byte)(value >> 56);
                ProtoWriter.IncrementedAndReset(8, writer);
                return;
            }

            case WireType.String:
            case WireType.StartGroup:
            case WireType.EndGroup:
IL_36:
                if (wireType != WireType.SignedVariant)
                {
                    throw ProtoWriter.CreateException(writer);
                }
                ProtoWriter.WriteUInt64Variant(ProtoWriter.Zig(value), writer);
                writer.wireType = WireType.None;
                return;

            case WireType.Fixed32:
                ProtoWriter.WriteInt32(checked ((int)value), writer);
                return;
            }
            goto IL_36;
        }