public IEnumerable <KeyValuePair <Key, Value> > Enumerate() { byte[] key = null; byte[] value = null; bool data = true; while (data) { try { int keyLen = _reader.Read7BitEncodedInt(); key = _reader.ReadBytes(keyLen); if (key.Length != keyLen) { throw new InvalidOperationException(); } int valueLen = _reader.Read7BitEncodedInt(); value = _reader.ReadBytes(valueLen); if (valueLen <= 0 || valueLen != value.Length) { throw new InvalidOperationException(); } } catch (EndOfStreamException) { data = false; } catch (InvalidOperationException) { data = false; } if (data) { yield return(new KeyValuePair <Key, Value> (Key.FromBytes(key), Value.FromBytes(value))); } } }
public static Value Random(int numBytes) { return(Value.FromBytes(ByteArray.Random(numBytes).InternalBytes)); }