public void Update(TMessage curr)
                {
                    if (curr is null)
                    {
                        throw new ArgumentNullException(nameof(curr));
                    }

                    var key = _serializer.GetKey(curr);

                    lock (_snapshots.SyncRoot)
                    {
                        var prev = _snapshots.TryGetValue(key);

                        if (prev is null)
                        {
                            if (curr.SecurityId == default)
                            {
                                throw new ArgumentException(curr.ToString());
                            }

                            _snapshots.Add(key, curr.TypedClone());
                        }
                        else
                        {
                            _serializer.Update(prev, curr);
                        }

                        _dirtyKeys.Add(key);
                    }
                }
        void ISnapshotStorage.Update(Message message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var curr = (TMessage)message;

            var secId = _serializer.GetSecurityId(curr);

            lock (_snapshots.SyncRoot)
            {
                var tuple = _snapshots.TryGetValue(secId);

                if (tuple == null)
                {
                    _snapshots.Add(secId, Tuple.Create(_maxOffset, (TMessage)curr.Clone()));
                    _maxOffset += _snapshotSize;
                }
                else
                {
                    _serializer.Update(tuple.Item2, curr);
                }

                _dirtySecurities.Add(secId);
            }
        }
示例#3
0
                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);
                    }
                }