/// <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); } }
/// <summary> /// Writes a decimal to a UcAsp.RPC.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); }
/// <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); }
/// <summary> /// Writes a boolean to the stream; supported wire-types: Variant, Fixed32, Fixed64 /// </summary> public static void WriteBoolean(bool value, ProtoWriter writer) { ProtoWriter.WriteUInt32(value ? (uint)1 : (uint)0, writer); }