当前位置: 首页>>代码示例>>C#>>正文


C# IProgressMonitor.Done方法代码示例

本文整理汇总了C#中IProgressMonitor.Done方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressMonitor.Done方法的具体用法?C# IProgressMonitor.Done怎么用?C# IProgressMonitor.Done使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProgressMonitor的用法示例。


在下文中一共展示了IProgressMonitor.Done方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunFindReferences

		/// <summary>
		/// This method can be used in three modes:
		/// 1. Find references to classes (parentClass = targetClass, member = null, isLocal = false)
		/// 2. Find references to members (parentClass = parent, member = member, isLocal = false)
		/// 3. Find references to local variables (parentClass = parent, member = local var as field, isLocal = true)
		/// </summary>
		static List<Reference> RunFindReferences(IClass ownerClass, IMember member,
		                                         bool isLocal,
		                                         IProgressMonitor progressMonitor)
		{
			if (ParserService.LoadSolutionProjectsThreadRunning) {
				if (progressMonitor != null) progressMonitor.ShowingDialog = true;
				MessageService.ShowMessage("${res:SharpDevelop.Refactoring.LoadSolutionProjectsThreadRunning}");
				if (progressMonitor != null) progressMonitor.ShowingDialog = false;
				return null;
			}
			List<ProjectItem> files;
			if (isLocal) {
				files = new List<ProjectItem>();
				files.Add(FindItem(ownerClass.CompilationUnit.FileName));
			} else {
				ownerClass = ownerClass.GetCompoundClass();
				files = GetPossibleFiles(ownerClass, member);
			}
			ParseableFileContentEnumerator enumerator = new ParseableFileContentEnumerator(files.ToArray());
			List<Reference> references = new List<Reference>();
			try {
				if (progressMonitor != null) {
					progressMonitor.BeginTask("${res:SharpDevelop.Refactoring.FindingReferences}", files.Count, true);
				}
				#if DEBUG
				if (System.Windows.Forms.Control.ModifierKeys == DefaultEditor.Gui.Editor.SharpDevelopTextAreaControl.DebugBreakModifiers) {
					System.Diagnostics.Debugger.Break();
				}
				#endif
				while (enumerator.MoveNext()) {
					if (progressMonitor != null) {
						progressMonitor.WorkDone = enumerator.Index;
						if (progressMonitor.IsCancelled) {
							return null;
						}
					}
					
					AddReferences(references, ownerClass, member, isLocal, enumerator.CurrentFileName, enumerator.CurrentFileContent);
				}
			} finally {
				if (progressMonitor != null) {
					progressMonitor.Done();
				}
				enumerator.Dispose();
			}
			return references;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:53,代码来源:RefactoringService.cs

示例2: FindReferences

		/// <summary>
		/// Finds all references to resources (except the definition) using the specified
		/// <see cref="IResourceReferenceFinder"/> object.
		/// </summary>
		/// <param name="finder">The <see cref="IResourceReferenceFinder"/> to use to find resource references.</param>
		/// <param name="monitor">An object implementing <see cref="IProgressMonitor"/> to report the progress of the operation. Can be <c>null</c>.</param>
		/// <param name="scope">The scope which should be searched.</param>
		/// <returns>A list of references to resources.</returns>
		public static List<Reference> FindReferences(IResourceReferenceFinder finder, IProgressMonitor monitor, SearchScope scope)
		{
			if (finder == null) {
				throw new ArgumentNullException("finder");
			}
			
			if (ParserService.LoadSolutionProjectsThreadRunning) {
				if (monitor != null) monitor.ShowingDialog = true;
				MessageService.ShowMessage("${res:SharpDevelop.Refactoring.LoadSolutionProjectsThreadRunning}");
				if (monitor != null) monitor.ShowingDialog = false;
				return null;
			}
			
			DateTime startTime = DateTime.UtcNow;
			
			List<Reference> references = new List<Reference>();
			
			try {
				
				NRefactoryAstCacheService.EnableCache();
				
				ICollection<string> files = GetPossibleFiles(scope);
				
				if (monitor != null) {
					monitor.BeginTask("${res:SharpDevelop.Refactoring.FindingReferences}", files.Count, true);
				}
				
				foreach (string fileName in files) {
					
					if (monitor != null && monitor.IsCancelled) {
						return null;
					}
					
					IDocument doc = null;
					try {
						// The following line throws an exception if the file does not exist.
						// But the file may be in an unsaved view content (which would be found by GetDocumentInformation),
						// so we cannot simply loop on !File.Exists(...).
						doc = FindReferencesAndRenameHelper.GetDocumentInformation(fileName).CreateDocument();
					} catch (FileNotFoundException) {
					}
					if (doc == null) {
						if (monitor != null) ++monitor.WorkDone;
						continue;
					}
					
					string fileContent = doc.TextContent;
					if (String.IsNullOrEmpty(fileContent)) {
						if (monitor != null) ++monitor.WorkDone;
						continue;
					}
					
					int pos = -1;
					while ((pos = finder.GetNextPossibleOffset(fileName, fileContent, pos)) >= 0) {
						
						TextLocation docPos = doc.OffsetToPosition(pos);
						ResourceResolveResult rrr = ResourceResolverService.Resolve(fileName, doc, docPos.Y, docPos.X, null);
						
						if (rrr != null && rrr.ResourceFileContent != null) {
							if (finder.IsReferenceToResource(rrr)) {
								
								if (rrr.Key != null) {
									
									// The actual location of the key string may be after 'pos' because
									// the resolvers may find an expression just before it.
									string keyString = rrr.Key;
									int keyPos = fileContent.IndexOf(keyString, pos, StringComparison.OrdinalIgnoreCase);
									
									if (keyPos < pos) {
										// The key may be escaped in some way in the document.
										// Try using the code generator to find this out.
										keyPos = FindStringLiteral(fileName, fileContent, rrr.Key, pos, out keyString);
									}
									
									if (keyPos < pos) {
										if (monitor != null) monitor.ShowingDialog = true;
										MessageService.ShowWarning("ResourceToolkit: The key '"+rrr.Key+"' could not be located at the resolved position in the file '"+fileName+"'.");
										if (monitor != null) monitor.ShowingDialog = false;
									} else {
										references.Add(new Reference(fileName, keyPos, keyString.Length, keyString, rrr));
									}
									
								} else {
									references.Add(new Reference(fileName, pos, 0, null, rrr));
								}
								
							}
						}
						
					}
					
					if (monitor != null) ++monitor.WorkDone;
//.........这里部分代码省略.........
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:101,代码来源:ResourceRefactoringService.cs

示例3: FindUnusedKeys

		/// <summary>
		/// Finds all unused resource keys in all resource files that are referenced
		/// in code at least once in the whole solution.
		/// </summary>
		/// <param name="monitor">An object implementing <see cref="IProgressMonitor"/> to report the progress of the operation. Can be <c>null</c>.</param>
		/// <returns>A collection of <see cref="ResourceItem"/> classes that represent the unused resource keys.</returns>
		public static ICollection<ResourceItem> FindUnusedKeys(IProgressMonitor monitor)
		{
			List<Reference> references = FindAllReferences(monitor, SearchScope.WholeSolution);
			if (references == null) {
				return null;
			}
			
			if (monitor != null) {
				monitor.BeginTask(null, 0, false);
			}
			
			List<ResourceItem> unused = new List<ResourceItem>();
			
			// Get a list of all referenced resource files.
			// Generate a dictonary of resource file names and the
			// corresponding referenced keys.
			Dictionary<string, List<string>> referencedKeys = new Dictionary<string, List<string>>();
			Dictionary<string, List<string>> referencedPrefixes = new Dictionary<string, List<string>>();
			foreach (Reference reference in references) {
				ResourceResolveResult rrr = (ResourceResolveResult)reference.ResolveResult;
				if (rrr.ResourceFileContent != null) {
					string fileName = rrr.FileName;
					if (!referencedKeys.ContainsKey(fileName)) {
						referencedKeys.Add(fileName, new List<string>());
						referencedPrefixes.Add(fileName, new List<string>());
					}
					if (rrr.Key != null && !referencedKeys[fileName].Contains(rrr.Key)) {
						referencedKeys[fileName].Add(rrr.Key);
					} else {
						ResourcePrefixResolveResult rprr = rrr as ResourcePrefixResolveResult;
						if (rprr != null && rprr.Prefix != null && !referencedPrefixes[fileName].Contains(rprr.Prefix)) {
							referencedPrefixes[fileName].Add(rprr.Prefix);
						}
					}
				} else {
					if (monitor != null) monitor.ShowingDialog = true;
					MessageService.ShowWarning("Found a resource reference that could not be resolved."+Environment.NewLine+(reference.FileName ?? "<null>")+":"+reference.Offset+Environment.NewLine+"Expression: "+(reference.Expression ?? "<null>"));
					if (monitor != null) monitor.ShowingDialog = false;
				}
			}
			
			// Find keys that are not referenced anywhere.
			foreach (string fileName in referencedKeys.Keys) {
				#if DEBUG
				LoggingService.Debug("ResourceToolkit: FindUnusedKeys: Referenced resource file '"+fileName+"'");
				#endif
				foreach (KeyValuePair<string, object> entry in ResourceFileContentRegistry.GetResourceFileContent(fileName).Data) {
					if (!referencedKeys[fileName].Contains(entry.Key) &&
					    !referencedPrefixes[fileName].Any(prefix => entry.Key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))) {
						unused.Add(new ResourceItem(fileName, entry.Key));
					}
				}
			}
			
			if (monitor != null) monitor.Done();
			
			return unused.AsReadOnly();
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:64,代码来源:ResourceRefactoringService.cs

示例4: Rename

		/// <summary>
		/// Renames all references to a resource including the definition.
		/// </summary>
		/// <param name="rrr">The resource to be renamed.</param>
		/// <param name="newKey">The new name of the resource key.</param>
		/// <param name="monitor">An object implementing <see cref="IProgressMonitor"/> to report the progress of the operation. Can be <c>null</c>.</param>
		public static void Rename(ResourceResolveResult rrr, string newKey, IProgressMonitor monitor)
		{
			// Prevent duplicate key names
			if (rrr.ResourceFileContent.ContainsKey(newKey)) {
				if (monitor != null) monitor.ShowingDialog = true;
				MessageService.ShowWarning("${res:Hornung.ResourceToolkit.EditStringResourceDialog.DuplicateKey}");
				if (monitor != null) monitor.ShowingDialog = false;
				return;
			}
			
			List<Reference> references = FindReferences(rrr.FileName, rrr.Key, monitor);
			if (references == null) {
				return;
			}
			
			if (monitor != null) {
				monitor.BeginTask(null, 0, false);
			}
			
			try {
				// rename definition (if present)
				if (rrr.ResourceFileContent.ContainsKey(rrr.Key)) {
					rrr.ResourceFileContent.RenameKey(rrr.Key, newKey);
				} else {
					if (monitor != null) monitor.ShowingDialog = true;
					MessageService.ShowWarning("${res:Hornung.ResourceToolkit.RenameKeyDefinitionNotFoundWarning}");
					if (monitor != null) monitor.ShowingDialog = false;
				}
			} catch (Exception ex) {
				if (monitor != null) monitor.ShowingDialog = true;
				MessageService.ShowWarningFormatted("${res:Hornung.ResourceToolkit.ErrorProcessingResourceFile}" + Environment.NewLine + ex.Message, rrr.ResourceFileContent.FileName);
				if (monitor != null) monitor.ShowingDialog = false;
				if (monitor != null) monitor.Done();
				// Do not rename the references when renaming the definition failed.
				return;
			}
			
			// rename references
			// FIXME: RenameReferences does not enforce escaping rules. May be a problem if someone uses double-quotes in the new resource key name.
			FindReferencesAndRenameHelper.RenameReferences(references, newKey);
			
			// rename definitions in localized resource files
			foreach (KeyValuePair<string, IResourceFileContent> entry in ResourceFileContentRegistry.GetLocalizedContents(rrr.FileName)) {
				try {
					if (entry.Value.ContainsKey(rrr.Key)) {
						entry.Value.RenameKey(rrr.Key, newKey);
					}
				} catch (Exception ex) {
					if (monitor != null) monitor.ShowingDialog = true;
					MessageService.ShowWarningFormatted("${res:Hornung.ResourceToolkit.ErrorProcessingResourceFile}" + Environment.NewLine + ex.Message, entry.Value.FileName);
					if (monitor != null) monitor.ShowingDialog = false;
				}
			}
			
			if (monitor != null) monitor.Done();
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:62,代码来源:ResourceRefactoringService.cs

示例5: CopyItems

		protected virtual void CopyItems(IProject sourceProject, IProject targetProject, IProgressMonitor monitor)
		{
			if (sourceProject == null)
				throw new ArgumentNullException("sourceProject");
			if (targetProject == null)
				throw new ArgumentNullException("targetProject");
			IProjectItemListProvider targetProjectItems = targetProject as IProjectItemListProvider;
			if (targetProjectItems == null)
				throw new ArgumentNullException("targetProjectItems");
			
			ICollection<ProjectItem> sourceItems = sourceProject.Items;
			int totalWork = 0;
			foreach (ProjectItem item in sourceItems) {
				totalWork += GetRequiredWork(item);
			}
			
			monitor.BeginTask("Converting", totalWork, true);
			int workDone = 0;
			foreach (ProjectItem item in sourceItems) {
				FileProjectItem fileItem = item as FileProjectItem;
				if (fileItem != null && FileUtility.IsBaseDirectory(sourceProject.Directory, fileItem.FileName)) {
					FileProjectItem targetItem = new FileProjectItem(targetProject, fileItem.ItemType);
					fileItem.CopyMetadataTo(targetItem);
					targetItem.Include = fileItem.Include;
					if (File.Exists(fileItem.FileName)) {
						if (!Directory.Exists(Path.GetDirectoryName(targetItem.FileName))) {
							Directory.CreateDirectory(Path.GetDirectoryName(targetItem.FileName));
						}
						try {
							ConvertFile(fileItem, targetItem);
						} catch (Exception ex) {
							throw new ConversionException("Error converting " + fileItem.FileName, ex);
						}
					}
					targetProjectItems.AddProjectItem(targetItem);
				} else {
					targetProjectItems.AddProjectItem(item.CloneFor(targetProject));
				}
				if (monitor.IsCancelled) {
					return;
				}
				workDone += GetRequiredWork(item);
				monitor.WorkDone = workDone;
			}
			monitor.Done();
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:46,代码来源:LanguageConverter.cs


注:本文中的IProgressMonitor.Done方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。