/// <summary> /// Writes a decimal to a protobuf stream /// </summary> public static void WriteDecimal(decimal value, ProtoWriter writer) { int[] bits = decimal.GetBits(value); ulong a = ((ulong)bits[1]) << 32, b = ((ulong)bits[0]) & 0xFFFFFFFFL; ulong low = a | b; uint high = (uint)bits[2]; uint signScale = (uint)(((bits[3] >> 15) & 0x01FE) | ((bits[3] >> 31) & 0x0001)); SubItemToken token = ProtoWriter.StartSubItem(null, writer); if (low != 0) { ProtoWriter.WriteFieldHeader(FieldDecimalLow, WireType.Variant, writer); ProtoWriter.WriteUInt64(low, writer); } if (high != 0) { ProtoWriter.WriteFieldHeader(FieldDecimalHigh, WireType.Variant, writer); ProtoWriter.WriteUInt32(high, writer); } if (signScale != 0) { ProtoWriter.WriteFieldHeader(FieldDecimalSignScale, WireType.Variant, writer); ProtoWriter.WriteUInt32(signScale, writer); } ProtoWriter.EndSubItem(token, writer); }
public static void WriteDecimal(decimal value, ProtoWriter writer) { int[] bits = decimal.GetBits(value); long num = (long)bits[1] << 32; ulong num2 = (ulong)(bits[0] & uint.MaxValue); ulong num3 = (ulong)(num | (long)num2); uint num4 = (uint)bits[2]; uint num5 = (uint)(((bits[3] >> 15) & 0x1FE) | ((bits[3] >> 31) & 1)); SubItemToken token = ProtoWriter.StartSubItem(null, writer); if (num3 != 0L) { ProtoWriter.WriteFieldHeader(1, WireType.Variant, writer); ProtoWriter.WriteUInt64(num3, writer); } if (num4 != 0) { ProtoWriter.WriteFieldHeader(2, WireType.Variant, writer); ProtoWriter.WriteUInt32(num4, writer); } if (num5 != 0) { ProtoWriter.WriteFieldHeader(3, WireType.Variant, writer); ProtoWriter.WriteUInt32(num5, writer); } ProtoWriter.EndSubItem(token, writer); }
/// <summary> /// Writes an unsigned 64-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64 /// </summary> public static void WriteUInt64(ulong value, ProtoWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } switch (writer.wireType) { case WireType.Fixed64: ProtoWriter.WriteInt64((long)value, writer); return; case WireType.Variant: WriteUInt64Variant(value, writer); writer.wireType = WireType.None; return; case WireType.Fixed32: checked { ProtoWriter.WriteUInt32((uint)value, writer); } return; default: throw CreateException(writer); } }
public static void WriteDecimal(decimal value, ProtoWriter writer) { int[] bits = decimal.GetBits(value); ulong num = (ulong)((long)bits[1] << 32); ulong num1 = (long)bits[0] & (ulong)-1; ulong num2 = num | num1; uint num3 = (uint)bits[2]; uint num4 = (uint)(bits[3] >> 15 & 510 | bits[3] >> 31 & 1); SubItemToken subItemToken = ProtoWriter.StartSubItem(null, writer); if (num2 != (long)0) { ProtoWriter.WriteFieldHeader(1, WireType.Variant, writer); ProtoWriter.WriteUInt64(num2, writer); } if (num3 != 0) { ProtoWriter.WriteFieldHeader(2, WireType.Variant, writer); ProtoWriter.WriteUInt32(num3, writer); } if (num4 != 0) { ProtoWriter.WriteFieldHeader(3, WireType.Variant, writer); ProtoWriter.WriteUInt32(num4, writer); } ProtoWriter.EndSubItem(subItemToken, writer); }
public static void WriteDecimal(decimal value, ProtoWriter writer) { int[] bits = decimal.GetBits(value); ulong num = (ulong)((ulong)((long)bits[1]) << 32); ulong num2 = (ulong)((long)bits[0] & (long)((ulong)-1)); ulong num3 = num | num2; uint num4 = (uint)bits[2]; uint num5 = (uint)((bits[3] >> 15 & 510) | (bits[3] >> 31 & 1)); SubItemToken token = ProtoWriter.StartSubItem(null, writer); if (num3 != 0uL) { ProtoWriter.WriteFieldHeader(1, WireType.Variant, writer); ProtoWriter.WriteUInt64(num3, writer); } if (num4 != 0u) { ProtoWriter.WriteFieldHeader(2, WireType.Variant, writer); ProtoWriter.WriteUInt32(num4, writer); } if (num5 != 0u) { ProtoWriter.WriteFieldHeader(3, WireType.Variant, writer); ProtoWriter.WriteUInt32(num5, writer); } ProtoWriter.EndSubItem(token, writer); }
// 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); }
/// <summary> /// Writes a decimal to a protobuf stream /// </summary> public static void WriteDecimal(decimal value, ProtoWriter writer) { var dec = new DecimalAccessor(value); ulong a = ((ulong)dec.Mid) << 32, b = ((ulong)dec.Lo) & 0xFFFFFFFFL; ulong low = a | b; uint high = (uint)dec.Hi; uint signScale = (uint)(((dec.Flags >> 15) & 0x01FE) | ((dec.Flags >> 31) & 0x0001)); SubItemToken token = ProtoWriter.StartSubItem(null, writer); if (low != 0) { ProtoWriter.WriteFieldHeader(FieldDecimalLow, WireType.Variant, writer); ProtoWriter.WriteUInt64(low, writer); } if (high != 0) { ProtoWriter.WriteFieldHeader(FieldDecimalHigh, WireType.Variant, writer); ProtoWriter.WriteUInt32(high, writer); } if (signScale != 0) { ProtoWriter.WriteFieldHeader(FieldDecimalSignScale, WireType.Variant, writer); ProtoWriter.WriteUInt32(signScale, writer); } ProtoWriter.EndSubItem(token, writer); }
/// <summary> /// Writes a boolean to the stream; supported wire-types: Variant, Fixed32, Fixed64 /// </summary> public static void WriteBoolean(bool value, ProtoWriter writer, ref State state) { ProtoWriter.WriteUInt32(value ? (uint)1 : (uint)0, writer, ref state); }
/// <summary> /// Writes an unsigned 8-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64 /// </summary> public static void WriteByte(byte value, ProtoWriter writer) { ProtoWriter.WriteUInt32(value, writer); }
/// <summary> /// Writes an unsigned 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64 /// </summary> public static void WriteUInt16(ushort value, ProtoWriter writer) { ProtoWriter.WriteUInt32(value, writer); }
public static void WriteBoolean(bool value, ProtoWriter writer) { ProtoWriter.WriteUInt32((uint)((value ? 1 : 0)), writer); }
public static void WriteBoolean(bool value, ProtoWriter writer) { ProtoWriter.WriteUInt32((!value) ? 0u : 1u, writer); }
// Token: 0x06000165 RID: 357 RVA: 0x00002EFE File Offset: 0x000010FE public static void WriteBoolean(bool value, ProtoWriter writer) { ProtoWriter.WriteUInt32(value ? 1u : 0u, writer); }