public byte[] PackNodes() { int count = 0; using (var packer = new Packer()) { packer.Pack(count); packer.Pack(Time.Timestamp); lock (_buckets) { foreach (var list in _buckets) { foreach (var nodeInfo in list) { nodeInfo.Pack(packer); count++; } } } var p = packer.Position; packer.Position = 0; packer.Pack(count); packer.Position = p; return(packer.ToByteArray()); } }
public byte[] ToArray() { using (var packer = new Packer()) { Pack(packer); return(packer.ToByteArray()); } }
public static string ToHex(Action <Packer> action) { try { using (var packer = new Packer()) { action.Invoke(packer); return(Hex.ToString(packer.ToByteArray())); } } catch (Exception ex) { Log.IgnoreException(ex); } return(null); }
public static byte[] Write(params Action <ChunkWriter>[] chunkedPackable) { try { using (var packWriter = new Packer()) { if (Write(packWriter, chunkedPackable)) { return(packWriter.ToByteArray()); } } } catch (Exception ex) { Log.IgnoreException(ex); } return(null); }