private static WriteUInt32Variant ( uint value, |
||
value | uint | |
writer | ||
Résultat | void |
/// <summary> /// Writes a string to the stream; supported wire-types: String /// </summary> public static void WriteString(string value, ProtoWriter writer) { if (writer.wireType != WireType.String) { throw CreateException(writer); } if (value == null) { throw new ArgumentNullException("value"); // written header; now what? } int len = value.Length; if (len == 0) { WriteUInt32Variant(0, writer); writer.wireType = WireType.None; return; // just a header } #if MF byte[] bytes = encoding.GetBytes(value); int actual = bytes.Length; writer.WriteUInt32Variant((uint)actual); writer.Ensure(actual); Helpers.BlockCopy(bytes, 0, writer.ioBuffer, writer.ioIndex, actual); #else int predicted = encoding.GetByteCount(value); WriteUInt32Variant((uint)predicted, writer); DemandSpace(predicted, writer); int actual = encoding.GetBytes(value, 0, value.Length, writer.ioBuffer, writer.ioIndex); Helpers.DebugAssert(predicted == actual); #endif IncrementedAndReset(actual, writer); }
// Token: 0x0600015A RID: 346 RVA: 0x0000DA5C File Offset: 0x0000BC5C public static void WriteUInt32(uint value, ProtoWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } WireType wireType = writer.wireType; if (wireType == WireType.Variant) { ProtoWriter.WriteUInt32Variant(value, writer); writer.wireType = WireType.None; return; } if (wireType == WireType.Fixed64) { ProtoWriter.WriteInt64((long)value, writer); return; } if (wireType == WireType.Fixed32) { ProtoWriter.WriteInt32((int)value, writer); return; } throw ProtoWriter.CreateException(writer); }
public static void WriteString(string value, ProtoWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } if (writer.wireType != ProtoBuf.WireType.String) { throw ProtoWriter.CreateException(writer); } if (value == null) { throw new ArgumentNullException("value"); } if (value.Length == 0) { ProtoWriter.WriteUInt32Variant(0, writer); writer.wireType = ProtoBuf.WireType.None; return; } int byteCount = ProtoWriter.encoding.GetByteCount(value); ProtoWriter.WriteUInt32Variant((uint)byteCount, writer); ProtoWriter.DemandSpace(byteCount, writer); int bytes = ProtoWriter.encoding.GetBytes(value, 0, value.Length, writer.ioBuffer, writer.ioIndex); ProtoWriter.IncrementedAndReset(bytes, writer); }
public static void WriteBytes(byte[] data, int offset, int length, ProtoWriter writer) { if (data == null) { throw new ArgumentNullException("data"); } if (writer == null) { throw new ArgumentNullException("writer"); } switch (writer.wireType) { case WireType.Fixed64: if (length != 8) { throw new ArgumentException("length"); } goto IL_D5; case WireType.String: ProtoWriter.WriteUInt32Variant((uint)length, writer); writer.wireType = WireType.None; if (length == 0) { return; } if (writer.flushLock != 0 || length <= writer.ioBuffer.Length) { goto IL_D5; } ProtoWriter.Flush(writer); writer.dest.Write(data, offset, length); writer.position += length; return; case WireType.Fixed32: if (length != 4) { throw new ArgumentException("length"); } goto IL_D5; } throw ProtoWriter.CreateException(writer); IL_D5: ProtoWriter.DemandSpace(length, writer); Helpers.BlockCopy(data, offset, writer.ioBuffer, writer.ioIndex, length); ProtoWriter.IncrementedAndReset(length, writer); }
// Token: 0x060034C3 RID: 13507 RVA: 0x001320A0 File Offset: 0x001304A0 public static void WriteBytes(byte[] data, int offset, int length, ProtoWriter writer) { if (data == null) { throw new ArgumentNullException("data"); } if (writer == null) { throw new ArgumentNullException("writer"); } WireType wireType = writer.wireType; if (wireType != WireType.Fixed32) { if (wireType != WireType.Fixed64) { if (wireType != WireType.String) { throw ProtoWriter.CreateException(writer); } ProtoWriter.WriteUInt32Variant((uint)length, writer); writer.wireType = WireType.None; if (length == 0) { return; } if (writer.flushLock == 0 && length > writer.ioBuffer.Length) { ProtoWriter.Flush(writer); writer.dest.Write(data, offset, length); writer.position += length; return; } } else if (length != 8) { throw new ArgumentException("length"); } } else if (length != 4) { throw new ArgumentException("length"); } ProtoWriter.DemandSpace(length, writer); Helpers.BlockCopy(data, offset, writer.ioBuffer, writer.ioIndex, length); ProtoWriter.IncrementedAndReset(length, writer); }
public static void WriteUInt32(uint value, ProtoWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } ProtoBuf.WireType wireType = writer.wireType; switch (wireType) { case ProtoBuf.WireType.Variant: { ProtoWriter.WriteUInt32Variant(value, writer); writer.wireType = ProtoBuf.WireType.None; return; } case ProtoBuf.WireType.Fixed64: { ProtoWriter.WriteInt64((long)value, writer); return; } default: { if (wireType != ProtoBuf.WireType.Fixed32) { break; } else { ProtoWriter.WriteInt32((int)value, writer); return; } } } throw ProtoWriter.CreateException(writer); }
/// <summary> /// Writes a string to the stream; supported wire-types: String /// </summary> public static void WriteString(string value, ProtoWriter writer) { if (writer.wireType != WireType.String) throw CreateException(writer); if (value == null) throw new ArgumentNullException("value"); // written header; now what? int len = value.Length; if (len == 0) { WriteUInt32Variant(0, writer); writer.wireType = WireType.None; return; // just a header } #if MF byte[] bytes = encoding.GetBytes(value); int actual = bytes.Length; writer.WriteUInt32Variant((uint)actual); writer.Ensure(actual); Helpers.BlockCopy(bytes, 0, writer.ioBuffer, writer.ioIndex, actual); #else int predicted = encoding.GetByteCount(value); WriteUInt32Variant((uint)predicted, writer); DemandSpace(predicted, writer); int actual = encoding.GetBytes(value, 0, value.Length, writer.ioBuffer, writer.ioIndex); Helpers.DebugAssert(predicted == actual); #endif IncrementedAndReset(actual, writer); }
public static void WriteInt32(int 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 >= 0) { ProtoWriter.WriteUInt32Variant((uint)value, writer); writer.wireType = ProtoBuf.WireType.None; return; } ProtoWriter.DemandSpace(10, writer); numArray = writer.ioBuffer; num = writer.ioIndex; numArray[num] = (byte)(value | 128); numArray[num + 1] = (byte)(value >> 7 | 128); numArray[num + 2] = (byte)(value >> 14 | 128); numArray[num + 3] = (byte)(value >> 21 | 128); numArray[num + 4] = (byte)(value >> 28 | 128); int num1 = 255; byte num2 = (byte)num1; numArray[num + 8] = (byte)num1; byte num3 = num2; byte num4 = num3; numArray[num + 7] = num3; byte num5 = num4; byte num6 = num5; numArray[num + 6] = num5; numArray[num + 5] = num6; 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); int num7 = 0; byte num8 = (byte)num7; numArray[num + 7] = (byte)num7; byte num9 = num8; byte num10 = num9; numArray[num + 6] = num9; byte num11 = num10; byte num12 = num11; numArray[num + 5] = num11; numArray[num + 4] = num12; ProtoWriter.IncrementedAndReset(8, writer); return; } default: { if (wireType == ProtoBuf.WireType.Fixed32) { break; } else { if (wireType != ProtoBuf.WireType.SignedVariant) { throw ProtoWriter.CreateException(writer); } ProtoWriter.WriteUInt32Variant(ProtoWriter.Zig(value), writer); writer.wireType = ProtoBuf.WireType.None; return; } } } ProtoWriter.DemandSpace(4, writer); ProtoWriter.WriteInt32ToBuffer(value, writer.ioBuffer, writer.ioIndex); ProtoWriter.IncrementedAndReset(4, writer); }
internal static void WriteHeaderCore(int fieldNumber, ProtoBuf.WireType wireType, ProtoWriter writer) { uint num = (uint)(fieldNumber << 3 | (int)(wireType & (ProtoBuf.WireType.Fixed64 | ProtoBuf.WireType.String | ProtoBuf.WireType.StartGroup | ProtoBuf.WireType.EndGroup | ProtoBuf.WireType.Fixed32))); ProtoWriter.WriteUInt32Variant(num, writer); }
public static void WriteBytes(byte[] data, int offset, int length, ProtoWriter writer) { if (data == null) { throw new ArgumentNullException("data"); } if (writer == null) { throw new ArgumentNullException("writer"); } switch (writer.wireType) { case ProtoBuf.WireType.Fixed64: { if (length == 8) { break; } throw new ArgumentException("length"); } case ProtoBuf.WireType.String: { ProtoWriter.WriteUInt32Variant((uint)length, writer); writer.wireType = ProtoBuf.WireType.None; if (length == 0) { return; } if (writer.flushLock != 0 || length <= (int)writer.ioBuffer.Length) { break; } ProtoWriter.Flush(writer); writer.dest.Write(data, offset, length); writer.position += length; return; } case ProtoBuf.WireType.StartGroup: case ProtoBuf.WireType.EndGroup: { throw ProtoWriter.CreateException(writer); } case ProtoBuf.WireType.Fixed32: { if (length == 4) { break; } throw new ArgumentException("length"); } default: { throw ProtoWriter.CreateException(writer); } } ProtoWriter.DemandSpace(length, writer); Helpers.BlockCopy(data, offset, writer.ioBuffer, writer.ioIndex, length); ProtoWriter.IncrementedAndReset(length, writer); }
public static void WriteInt32(int value, ProtoWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } WireType wireType = writer.wireType; switch (wireType) { case WireType.Variant: if (value >= 0) { ProtoWriter.WriteUInt32Variant((uint)value, writer); writer.wireType = WireType.None; } else { ProtoWriter.DemandSpace(10, writer); byte[] array = writer.ioBuffer; int num = writer.ioIndex; array[num] = (byte)(value | 128); array[num + 1] = (byte)(value >> 7 | 128); array[num + 2] = (byte)(value >> 14 | 128); array[num + 3] = (byte)(value >> 21 | 128); array[num + 4] = (byte)(value >> 28 | 128); array[num + 5] = (array[num + 6] = (array[num + 7] = (array[num + 8] = 255))); 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] = (array[num + 5] = (array[num + 6] = (array[num + 7] = 0))); 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.WriteUInt32Variant(ProtoWriter.Zig(value), writer); writer.wireType = WireType.None; return; case WireType.Fixed32: ProtoWriter.DemandSpace(4, writer); ProtoWriter.WriteInt32ToBuffer(value, writer.ioBuffer, writer.ioIndex); ProtoWriter.IncrementedAndReset(4, writer); return; } goto IL_36; }
internal static void WriteHeaderCore(int fieldNumber, WireType wireType, ProtoWriter writer) { uint value = (uint)(fieldNumber << 3 | (int)(wireType & (WireType)7)); ProtoWriter.WriteUInt32Variant(value, writer); }
// Token: 0x06000160 RID: 352 RVA: 0x0000DAB0 File Offset: 0x0000BCB0 public static void WriteInt32(int value, ProtoWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } WireType wireType = writer.wireType; if (wireType <= WireType.Fixed64) { if (wireType != WireType.Variant) { if (wireType == 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] = (array[num + 5] = (array[num + 6] = (array[num + 7] = 0))); ProtoWriter.IncrementedAndReset(8, writer); return; } } else { if (value >= 0) { ProtoWriter.WriteUInt32Variant((uint)value, writer); writer.wireType = WireType.None; return; } ProtoWriter.DemandSpace(10, writer); byte[] array = writer.ioBuffer; int num = writer.ioIndex; array[num] = (byte)(value | 128); array[num + 1] = (byte)(value >> 7 | 128); array[num + 2] = (byte)(value >> 14 | 128); array[num + 3] = (byte)(value >> 21 | 128); array[num + 4] = (byte)(value >> 28 | 128); array[num + 5] = (array[num + 6] = (array[num + 7] = (array[num + 8] = byte.MaxValue))); array[num + 9] = 1; ProtoWriter.IncrementedAndReset(10, writer); return; } } else { if (wireType == WireType.Fixed32) { ProtoWriter.DemandSpace(4, writer); ProtoWriter.WriteInt32ToBuffer(value, writer.ioBuffer, writer.ioIndex); ProtoWriter.IncrementedAndReset(4, writer); return; } if (wireType == WireType.SignedVariant) { ProtoWriter.WriteUInt32Variant(ProtoWriter.Zig(value), writer); writer.wireType = WireType.None; return; } } throw ProtoWriter.CreateException(writer); }