internal IDisposable CreateBlock(string blockName) { // Unit tests case if (_performanceMarkerBlockProviders == null || _performanceMarkerBlockProviders.Count == 0) { return(new Block()); } // Optimize for the most common case if (_performanceMarkerBlockProviders.Count == 1) { IDisposable block = _performanceMarkerBlockProviders[0].Value?.CreateBlock(blockName); if (block != null) { return(block); } } var providedBlocks = new FrugalList <IDisposable>(); for (int i = 0; i < _performanceMarkerBlockProviders.Count; i++) { providedBlocks.Add(_performanceMarkerBlockProviders[i].Value?.CreateBlock(blockName)); } return(new Block(providedBlocks)); }
public NormalizedSnapshotSpanCollection GetSpans(ITextSnapshot targetSnapshot) { if (targetSnapshot == null) { throw new ArgumentNullException("targetSnapshot"); } if (_unmappable) { return(NormalizedSnapshotSpanCollection.Empty); } NormalizedSnapshotSpanCollection results = this.GetSpans(targetSnapshot.TextBuffer); if ((results.Count > 0) && (results[0].Snapshot != targetSnapshot)) { FrugalList <SnapshotSpan> translatedSpans = new FrugalList <SnapshotSpan>(); foreach (SnapshotSpan s in results) { translatedSpans.Add(s.TranslateTo(targetSnapshot, _trackingMode)); } results = new NormalizedSnapshotSpanCollection(translatedSpans); } return(results); }