Пример #1
0
        private bool SearchText(IProjectItem projectItem, TextReader textReader, FindInFilesDialog.ProcessResult callback, FindInFilesResult previousResult)
        {
            string str1 = string.Empty;
            int    num1 = -1;
            string str2;
            int    num2;

            do
            {
                ++num1;
                str2 = textReader.ReadLine();
                if (str2 != null)
                {
                    num2 = str2.IndexOf(this.FindString, this.comparison);
                }
                else
                {
                    goto label_4;
                }
            }while (num2 < 0 || callback(projectItem, num1 + 1, num2 + 1, str2.Trim(), previousResult));
            return(false);

label_4:
            return(true);
        }
Пример #2
0
 private bool FindInFile(IProjectItem projectItem, FindInFilesDialog.ProcessResult callback, FindInFilesResult previousResult)
 {
     if (!this.IsTargetExtension(projectItem.DocumentType.DefaultFileExtension))
     {
         return(false);
     }
     try
     {
         if (Microsoft.Expression.Framework.Documents.PathHelper.FileExists(projectItem.DocumentReference.Path))
         {
             if (!projectItem.IsDirty)
             {
                 using (TextReader textReader = (TextReader) new StreamReader((Stream) new FileStream(projectItem.DocumentReference.Path, FileMode.Open, FileAccess.Read)))
                 {
                     if (!this.SearchText(projectItem, textReader, callback, previousResult))
                     {
                         return(false);
                     }
                 }
             }
             else
             {
                 string s = (string)null;
                 IReadableTextBuffer readableTextBuffer = projectItem.Document as IReadableTextBuffer;
                 if (readableTextBuffer != null)
                 {
                     s = readableTextBuffer.GetText(0, readableTextBuffer.Length);
                 }
                 else
                 {
                     CodeDocument codeDocument = projectItem.Document as CodeDocument;
                     if (codeDocument != null)
                     {
                         s = codeDocument.Document != null ? codeDocument.Document.Text : string.Empty;
                     }
                 }
                 if (s != null)
                 {
                     using (TextReader textReader = (TextReader) new StringReader(s))
                     {
                         if (!this.SearchText(projectItem, textReader, callback, previousResult))
                         {
                             return(false);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
     return(true);
 }