public void ReadEntryValue(BinaryReader reader, Aes256Encryptor encryptor, out TEntryValue value, out uint metadata) { metadata = reader.ReadUInt32(); byte[] bytes = packedFile.Find(metadata); byte[] array = encryptor.Decrypt(bytes); serializationStream.Position = 0L; serializationStream.Write(array, 0, array.Length); serializationStream.Position = 0L; indexValueType.ReadEntryValue(serializationReader, encryptor, out value, out var _); }
public void Update(TDocument document) { lock (transactionLockObject) { if (isDisposed) { throw new ObjectDisposedException("Can't use Update() after Dispose() or Delete()"); } if (isFieldIndexesInUse) { throw new InvalidOperationException("Can't use Update() before disposing the enumerable from a FindDocumentIds call"); } if (document == null) { if (DebugLogHandler != null) { DebugLogHandler("Update: null"); } throw new ArgumentException("Can't update a null document"); } if (DebugLogHandler != null) { if (fields == null) { fields = documentType.GetFields(); } StringBuilder stringBuilder = new StringBuilder("Update: document=\n"); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { stringBuilder.Append(fieldInfo.Name); stringBuilder.Append(" = "); stringBuilder.Append(fieldInfo.GetValue(document)); stringBuilder.Append('\n'); } DebugLogHandler(stringBuilder.ToString()); } if (document.Id == metadataDocumentId) { throw new ArgumentException("Document " + document.Id + " not found"); } byte[] array2 = packedFile.Find(document.Id); if (array2 == null) { throw new ArgumentException("Document " + document.Id + " not found"); } TDocument oldDocument = DecryptAndDeserialize(array2, document.Id); byte[] document2 = SerializeAndEncrypt(document); journalWriter.Start(); try { document.Id = packedFile.Update(document.Id, document2); fieldIndexes.Update(document, oldDocument); journalWriter.Finish(); journalPlayer.Play(); } catch (Exception) { journalWriter.Discard(); throw; } } }