public void Update(TMessage curr) { if (curr == null) { throw new ArgumentNullException(nameof(curr)); } var key = _serializer.GetKey(curr); lock (_snapshots.SyncRoot) { var prev = _snapshots.TryGetValue(key); if (prev == null) { _snapshots.Add(key, _serializer.CreateCopy(curr)); } else { _serializer.Update(prev, curr); } _dirtyKeys.Add(key); } }