Esempio n. 1
0
        /// <inheritdoc />
        public IEnumerable <Security> Lookup(SecurityLookupMessage criteria)
        {
            if (criteria == null)
            {
                throw new ArgumentNullException(nameof(criteria));
            }

            var secId = criteria.SecurityId.ToStringId(nullIfEmpty: true);

            var filter = secId.IsEmpty()
                                ? (criteria.IsLookupAll() ? string.Empty : criteria.SecurityId.SecurityCode)
                                : secId;

            var securities = _trie.Retrieve(filter);

            if (!secId.IsEmpty())
            {
                securities = securities.Where(s => s.Id.CompareIgnoreCase(secId));
            }

            return(securities.Filter(criteria));
        }
Esempio n. 2
0
        /// <inheritdoc />
        public void DeleteBy(SecurityLookupMessage criteria)
        {
            if (criteria.IsLookupAll())
            {
                _inner.Clear();
                Cleared?.Invoke();
                return;
            }

            Security[] toDelete;

            lock (_inner.SyncRoot)
            {
                toDelete = _inner.Values.Filter(criteria).ToArray();

                foreach (var security in toDelete)
                {
                    _inner.Remove(security.ToSecurityId());
                }
            }

            Removed?.Invoke(toDelete);
        }