internal static DateTimeOffset Deserialize(byte[] buffer, int offset) { var milliseconds = BeConverter.ToInt64(buffer, offset); return(UnixStart.AddTicks(TimeSpan.TicksPerMillisecond * milliseconds)); }
internal static byte[] Serialize(DateTimeOffset value) { var ticks = (value - UnixStart).Ticks; return(BeConverter.GetBytes(ticks / TimeSpan.TicksPerMillisecond)); }
public override long Deserialize(ushort protocolVersion, byte[] buffer, int offset, int length, IColumnInfo typeInfo) { return(BeConverter.ToInt64(buffer, offset)); }
public override byte[] Serialize(ushort protocolVersion, long value) { return(BeConverter.GetBytes(value)); }
private static byte[] GetProtocolString(string value) { var textBuffer = Encoding.UTF8.GetBytes(value); return(BeConverter.GetBytes((ushort)textBuffer.Length).Concat(textBuffer).ToArray()); }
public override byte[] Serialize(ushort protocolVersion, LocalTime value) { return(BeConverter.GetBytes(value.TotalNanoseconds)); }
internal static byte[] Serialize(DateTimeOffset value) { return(BeConverter.GetBytes(Convert.ToInt64(Math.Floor((value - UnixStart).TotalMilliseconds)))); }
internal static DateTimeOffset Deserialize(byte[] buffer, int offset) { return(UnixStart.AddMilliseconds(BeConverter.ToInt64(buffer, offset))); }
private static byte[] GetErrorBody(int code, string message) { // error body = [int] [string] return(BeConverter.GetBytes(code).Concat(GetProtocolString(message)).ToArray()); }