ReadString() публичный Метод

public ReadString ( ) : string
Результат string
		protected override void Run (object dataItem)
		{
			base.Run (dataItem);

			if (IdeApp.Workspace == null) return;
			if (IdeApp.Workbench.ActiveDocument == null || IdeApp.Workbench.ActiveDocument.FileName == FilePath.Null) return;

			var document = IdeApp.Workbench.ActiveDocument;

			ResolveResult resolveResult = null;
			object item = CurrentRefactoryOperationsHandler.GetItem (document, out resolveResult);

			IMethod method = item as IMethod;
			if (method == null)
				return;

			ISearchProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor(true, true);
			ThreadPool.QueueUserWorkItem((data) => 
			{
				try
				{
					ImplementationsFinder.Find(method, implementation =>
					{
						FileProvider fileProvider = new FileProvider(implementation.Region.FileName);
						TextDocument doc = new TextDocument();
						doc.Text = fileProvider.ReadString();
						int offset = doc.LocationToOffset(implementation.Region.BeginLine, implementation.Region.BeginColumn);
						while ((offset + implementation.Name.Length) < doc.TextLength)
						{
							if (doc.GetTextAt(offset, implementation.Name.Length) == implementation.Name)
							{
								break;
							}
							offset++;
						}

						monitor.ReportResult (new MonoDevelop.Ide.FindInFiles.SearchResult(fileProvider, offset, implementation.Name.Length));
					});
				}
				catch (Exception exception)
				{
					if (monitor != null)
					{
						monitor.ReportError("Error finding references", exception);
					}
					else
					{
						LoggingService.LogError("Error finding references", exception);
					}
				}
				finally
				{
					if (monitor != null)
					{
						monitor.Dispose();
					}
				}
			});
		}
Пример #2
0
 TextEditor GetDocument()
 {
     if (cachedEditor == null || cachedEditor.FileName != FileName)
     {
         var content = FileProvider.ReadString();
         cachedEditor?.Dispose();
         cachedEditor = TextEditorFactory.CreateNewEditor(TextEditorFactory.CreateNewReadonlyDocument(new Core.Text.StringTextSource(content.ReadToEnd()), FileName, DesktopService.GetMimeTypeForUri(FileName)));
     }
     return(cachedEditor);
 }
Пример #3
0
        TextEditor GetDocument()
        {
            var fileProvider = FileProvider;

            if (cachedEditor == null || cachedEditor.IsDisposed || cachedEditor.FileName != FileName || cachedEditorFileProvider != fileProvider)
            {
                if (fileProvider == null)
                {
                    throw new InvalidOperationException("FileProvider == null");
                }
                var content = FileProvider.ReadString();
                if (content == null)
                {
                    throw new InvalidOperationException("FileProvider.ReadString () == null");
                }
                cachedEditor?.Dispose();
                cachedEditor             = TextEditorFactory.CreateNewEditor(TextEditorFactory.CreateNewReadonlyDocument(new Core.Text.StringTextSource(content.ReadToEnd()), FileName, IdeServices.DesktopService.GetMimeTypeForUri(FileName)));
                cachedEditorFileProvider = FileProvider;
            }
            return(cachedEditor);
        }
Пример #4
0
        IEnumerable <SearchResult> FindAll(IProgressMonitor monitor, FileProvider provider, string pattern, string replacePattern, FilterOptions filter)
        {
            if (string.IsNullOrEmpty(pattern))
            {
                return(Enumerable.Empty <SearchResult> ());
            }
            string content;

            try {
                content = provider.ReadString();
                if (content == null)
                {
                    return(Enumerable.Empty <SearchResult> ());
                }
            } catch (Exception e) {
                LoggingService.LogError("Error while reading file", e);
                return(Enumerable.Empty <SearchResult> ());
            }
            if (filter.RegexSearch)
            {
                return(RegexSearch(monitor, provider, content, replacePattern, filter));
            }
            return(Search(provider, content, pattern, replacePattern, filter));
        }
Пример #5
0
		IEnumerable<SearchResult> FindAll (IProgressMonitor monitor, FileProvider provider, string pattern, string replacePattern, FilterOptions filter)
		{
			if (string.IsNullOrEmpty (pattern))
				return Enumerable.Empty<SearchResult> ();
			string content;
			try {
				content = provider.ReadString ();
				if (content == null)
					return Enumerable.Empty<SearchResult> ();
			} catch (Exception e) {
				LoggingService.LogError ("Error while reading file", e);
				return Enumerable.Empty<SearchResult> ();
			}
			if (filter.RegexSearch)
				return RegexSearch (monitor, provider, content, replacePattern, filter);
			return Search (provider, content, pattern, replacePattern, filter);
		}