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
              };
            }
          }
        }
      }
    }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 /// <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;
 }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <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)
        {
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <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);
        }
Ejemplo n.º 8
0
 /// <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;
 }
Ejemplo n.º 9
0
        /// <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)
        {
        }