public IEnumerable<ISearchResult> FindAllForwardOnly(ITextSource document, int offset, int length) { var xc = new XPathCollection(); try { xc.Add(_xPath); } catch (Exception) { yield break; } using (var reader = new XmlTextReader(document.CreateReader())) using (var xpathReader = new XPathReader(reader, xc)) { var lineInfo = xpathReader as IXmlLineInfo; var doc = (IDocument)document; ISegment segment; while (Read(xpathReader)) { if (xpathReader.Match(0) && xpathReader.NodeType != XmlNodeType.EndElement) { segment = null; try { segment = XmlSegment(doc, lineInfo.LineNumber, lineInfo.LinePosition); } catch (Exception) { } if (segment != null && segment.Offset >= offset && segment.EndOffset <= (offset + length)) { yield return new XPathSearchResult() { StartOffset = segment.Offset, Length = segment.Length }; } } } } }
/// <include file='doc\XPathReader.uex' path='docs/doc[@for="XPathReader.XPathReader1"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Initializes a new instance of the XPathReader class with the specified XmlNameTable. /// This constructor is used when creating reader with "new XPathReader(..)"</para> /// </devdoc> // // For class function provides the url, we will construct the // XmlTextReader to process the URL // public XPathReader(TextReader reader, string xpath) : this() { this.reader = new XmlTextReader(reader); xpathCollection = new XPathCollection(); xpathCollection.Add(xpath); }
/// <include file='doc\XPathReader.uex' path='docs/doc[@for="XPathReader.XmlTextReader1"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Initializes a new instance of the XPathReader class with the specified XmlNameTable. /// This constructor is used when creating reader with "new XPathReader(..)"</para> /// </devdoc> public XPathReader(XmlReader reader, XPathCollection xc) : this() { xpathCollection = xc; xc.SetReader = this; this.reader = reader; }
/// <include file='doc\XPathReader.uex' path='docs/doc[@for="XPathReader.XPathReader1"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Initializes a new instance of the XPathReader class with the specified XmlNameTable. /// This constructor is used when creating reader with "new XPathReader(..)"</para> /// </devdoc> // // For class function provides the url, we will construct the // XmlTextReader to process the URL // public XPathReader(string url, string xpath) : this() { this.reader = new XmlTextReader(url); xpathCollection = new XPathCollection(); xpathCollection.Add(xpath); }
/// <include file='doc\XPathReader.uex' path='docs/doc[@for="XPathReader.XPathReader1"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Initializes a new instance of the XPathReader class with the specified XmlNameTable. /// This constructor is used when creating reader with "new XPathReader(..)"</para> /// </devdoc> // // For class function provides the url, we will construct the // XmlTextReader to process the URL // public XPathReader(string url, XPathCollection xc) : this(new XmlTextReader(url), xc) { }
/// <include file='doc\XPathReader.uex' path='docs/doc[@for="XPathReader.XPathReader1"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Initializes a new instance of the XPathReader class with the specified XmlNameTable. /// This constructor is used when creating reader with "new XPathReader(..)"</para> /// </devdoc> // // For class function provides the url, we will construct the // XmlTextReader to process the URL // public XPathReader(TextReader reader, string xpath) : this() { this.reader = new XmlTextReader(reader); xpathCollection = new XPathCollection(); xpathCollection.Add(xpath); }
/// <include file='doc\XPathReader.uex' path='docs/doc[@for="XPathReader.XPathReader1"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Initializes a new instance of the XPathReader class with the specified XmlNameTable. /// This constructor is used when creating reader with "new XPathReader(..)"</para> /// </devdoc> // // For class function provides the url, we will construct the // XmlTextReader to process the URL // public XPathReader(string url, string xpath) : this(){ this.reader = new XmlTextReader(url); xpathCollection = new XPathCollection(); xpathCollection.Add(xpath); }
/// <include file='doc\XPathReader.uex' path='docs/doc[@for="XPathReader.XmlTextReader1"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Initializes a new instance of the XPathReader class with the specified XmlNameTable. /// This constructor is used when creating reader with "new XPathReader(..)"</para> /// </devdoc> public XPathReader(XmlReader reader, XPathCollection xc) : this() { xpathCollection = xc; xc.SetReader = this; this.reader = reader; }
/// <include file='doc\XPathReader.uex' path='docs/doc[@for="XPathReader.XPathReader1"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Initializes a new instance of the XPathReader class with the specified XmlNameTable. /// This constructor is used when creating reader with "new XPathReader(..)"</para> /// </devdoc> // // For class function provides the url, we will construct the // XmlTextReader to process the URL // public XPathReader(string url, XPathCollection xc) : this(new XmlTextReader(url), xc) { }