ulong IIdentifier <T> .Add(T item) { lock (_gate) { return(_inner.Add(item)); } }
ulong IIdentifier <T> .Add(T item) { if (_inner.TryGetValue(item, out var code)) { return(code); } while (_queue.Count >= _count) { var head = _queue.Dequeue(); _inner.Remove(head); } return(_inner.Add(item)); }
private bool TryUpdate(Row row) { var breakpoint = row.Breakpoint; if (breakpoint.Id == 0) { breakpoint.Id = _rows.Add(row); } IEnumerable <KeyValuePair <object, SourceRange> > options; var functionBreakpoint = row.FunctionBreakpoint; if (functionBreakpoint != null) { options = from sourceItem in _sourceByItem let item = sourceItem.Key let name = _codeModel.NameFor(item) where name.IndexOf(functionBreakpoint.Name, StringComparison.CurrentCultureIgnoreCase) >= 0 orderby name.Length select sourceItem; } else { options = from sourceItem in _sourceByItem let source = sourceItem.Value where PathEquals(source.Path, row.Source.Path) where source.StartPoint?.LineIndex <= row.SourceBreakpoint.Line && source.EndPoint?.LineIndex >= row.SourceBreakpoint.Line let distance = row.SourceBreakpoint.Line - source.StartPoint.LineIndex orderby distance select sourceItem; } options = options.ToArray(); var best = options.FirstOrDefault(); return(TryUpdate(row, best)); }