//skip comments //TODO unescape escaped sequences public override int Read() { if (_cache.Count > 0) { return(_cache.Dequeue()); } int p = _reader.Read(); if (p <= 0) { return(p); } var c = unchecked ((char)p); if (c != '/') { return(p); } _cache.Enqueue(c); p = _reader.Read(); if (p <= 0) { return(_cache.Dequeue()); } c = unchecked ((char)p); if (c != '*') { return(_cache.Dequeue()); } _cache.Clear(); _reader.Read(); //consume the '*' bool hasStar = false; while (true) { var next = _reader.Read(); if (next <= 0) { return(next); } if (unchecked ((char)next) == '*') { hasStar = true; } else if (hasStar && unchecked ((char)next) == '/') { return(Read()); //recursively call self for comments following comments } else { hasStar = false; } } }
internal static T FindDescendantView <T>(this UIView view) where T : UIView { var queue = new FormsQueue <UIView>(); queue.Enqueue(view); while (queue.Count > 0) { var descendantView = queue.Dequeue(); var result = descendantView as T; if (result != null) { return(result); } for (var i = 0; i < descendantView.Subviews?.Length; i++) { queue.Enqueue(descendantView.Subviews[i]); } } return(null); }