protected IEnumerable <HexSpan> GetValidSpans(HexBuffer buffer, HexPosition start, HexPosition upperBounds) { var pos = start; bool fullSpan = true; while (pos < HexPosition.MaxEndPosition) { var span = buffer.GetNextValidSpan(pos, upperBounds, fullSpan); if (span == null) { break; } var newStart = HexPosition.Max(pos, span.Value.Start); var newEnd = HexPosition.Min(upperBounds, span.Value.End); if (newStart < newEnd) { yield return(HexSpan.FromBounds(newStart, newEnd)); } pos = span.Value.End; fullSpan = false; } }