protected internal Key ParseKey() { byte[] digest = null; string ns = null; string setName = null; Value userKey = null; for (int i = 0; i < fieldCount; i++) { int fieldlen = ByteUtil.BytesToInt(dataBuffer, dataOffset); dataOffset += 4; int fieldtype = dataBuffer[dataOffset++]; int size = fieldlen - 1; switch (fieldtype) { case FieldType.DIGEST_RIPE: digest = new byte[size]; Array.Copy(dataBuffer, dataOffset, digest, 0, size); dataOffset += size; break; case FieldType.NAMESPACE: ns = ByteUtil.Utf8ToString(dataBuffer, dataOffset, size); dataOffset += size; break; case FieldType.TABLE: setName = ByteUtil.Utf8ToString(dataBuffer, dataOffset, size); dataOffset += size; break; case FieldType.KEY: int type = dataBuffer[dataOffset++]; size--; userKey = ByteUtil.BytesToKeyValue(type, dataBuffer, dataOffset, size); dataOffset += size; break; } } return(new Key(ns, digest, setName, userKey)); }
protected internal Key ParseKey(int fieldCount) { byte[] digest = null; string ns = null; string setName = null; Value userKey = null; for (int i = 0; i < fieldCount; i++) { ReadBytes(4); int fieldlen = ByteUtil.BytesToInt(dataBuffer, 0); ReadBytes(fieldlen); int fieldtype = dataBuffer[0]; int size = fieldlen - 1; switch (fieldtype) { case FieldType.DIGEST_RIPE: digest = new byte[size]; Array.Copy(dataBuffer, 1, digest, 0, size); break; case FieldType.NAMESPACE: ns = ByteUtil.Utf8ToString(dataBuffer, 1, size); break; case FieldType.TABLE: setName = ByteUtil.Utf8ToString(dataBuffer, 1, size); break; case FieldType.KEY: userKey = ByteUtil.BytesToKeyValue(dataBuffer[1], dataBuffer, 2, size - 1); break; } } return(new Key(ns, digest, setName, userKey)); }