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


C# FileNode.InsertSorted方法代码示例

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


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

示例1: Run

		public override void Run()
		{
			WebReferenceNode node = Owner as WebReferenceNode;
			if (node != null && node.Project != null && node.ProjectItem != null) {
				WebReferenceUrl url = (WebReferenceUrl)node.ProjectItem;
				try {
					// Discover web services at url.
					DiscoveryClientProtocol protocol = DiscoverWebServices(url.UpdateFromURL);
					if (protocol != null) {
						// Save web services.
						WebReference webReference = new WebReference(url.Project, url.UpdateFromURL, node.Text, url.Namespace, protocol);
						webReference.Save();
						
						// Update project.
						WebReferenceChanges changes = webReference.GetChanges(url.Project);
						if (changes.Changed) {
							foreach (ProjectItem itemRemoved in changes.ItemsRemoved) {
								ProjectService.RemoveProjectItem(url.Project, itemRemoved);
								FileService.RemoveFile(itemRemoved.FileName, false);
							}
							foreach (ProjectItem newItem in changes.NewItems) {
								ProjectService.AddProjectItem(url.Project, newItem);
								FileNode fileNode = new FileNode(newItem.FileName, FileNodeStatus.InProject);
								fileNode.InsertSorted(node);
							}
							ProjectBrowserPad.Instance.ProjectBrowserControl.TreeView.Sort();
							url.Project.Save();
						}
						
						// Update code completion.
						SD.ParserService.ParseFileAsync(FileName.Create(webReference.WebProxyFileName), parentProject: url.Project).FireAndForget();
					}
				} catch (WebException ex) {
					LoggingService.Debug(ex);
					MessageService.ShowError(GetRefreshWebReferenceErrorMessage(ex, url.UpdateFromURL));
				}
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:38,代码来源:ReferenceFolderNodeCommands.cs

示例2: Run

		public override void Run()
		{
			WebReferenceNode node = Owner as WebReferenceNode;
			if (node != null && node.Project != null && node.ProjectItem != null) {
				WebReferenceUrl url = (WebReferenceUrl)node.ProjectItem;
				try {
					// Discover web services at url.
					DiscoveryClientProtocol protocol = DiscoverWebServices(url.UpdateFromURL);
					if (protocol != null) {
						// Save web services.
						WebReference webReference = new WebReference(url.Project, url.UpdateFromURL, node.Text, url.Namespace, protocol);
						webReference.Save();
						
						// Update project.
						WebReferenceChanges changes = webReference.GetChanges(url.Project);
						if (changes.Changed) {
							foreach (ProjectItem itemRemoved in changes.ItemsRemoved) {
								ProjectService.RemoveProjectItem(url.Project, itemRemoved);
								FileService.RemoveFile(itemRemoved.FileName, false);
							}
							foreach (ProjectItem newItem in changes.NewItems) {
								ProjectService.AddProjectItem(url.Project, newItem);
								FileNode fileNode = new FileNode(newItem.FileName, FileNodeStatus.InProject);
								fileNode.InsertSorted(node);
							}
							ProjectBrowserPad.Instance.ProjectBrowserControl.TreeView.Sort();
							url.Project.Save();
						}
						
						// Update code completion.
						ParserService.ParseFile(webReference.WebProxyFileName);
					}
				} catch (WebException ex) {
					MessageService.ShowException(ex, String.Format(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.ProjectBrowser.RefreshWebReference.ReadServiceDescriptionError}"), url.UpdateFromURL));
				}
			}
		}
开发者ID:trecio,项目名称:SharpDevelop,代码行数:37,代码来源:ReferenceFolderNodeCommands.cs

示例3: AddExistingItems

		protected IEnumerable<FileProjectItem> AddExistingItems()
		{
			DirectoryNode node = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedDirectoryNode;
			if (node == null) {
				return null;
			}
			node.Expanding();
			node.Expand();
			
			List<FileProjectItem> addedItems = new List<FileProjectItem>();
			
			using (OpenFileDialog fdiag  = new OpenFileDialog()) {
				fdiag.AddExtension = true;
				var fileFilters    = ProjectService.GetFileFilters();
				
				fdiag.InitialDirectory = node.Directory;
				fdiag.FilterIndex     = GetFileFilterIndex(node.Project, fileFilters);
				fdiag.Filter          = String.Join("|", fileFilters);
				fdiag.Multiselect     = true;
				fdiag.CheckFileExists = true;
				fdiag.Title = StringParser.Parse("${res:ProjectComponent.ContextMenu.AddExistingFiles}");
				
				if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window) == DialogResult.OK) {
					List<KeyValuePair<string, string>> fileNames = new List<KeyValuePair<string, string>>(fdiag.FileNames.Length);
					foreach (string fileName in fdiag.FileNames) {
						fileNames.Add(new KeyValuePair<string, string>(fileName, ""));
					}
					bool addedDependentFiles = false;
					foreach (string fileName in fdiag.FileNames) {
						foreach (string additionalFile in FindAdditionalFiles(fileName)) {
							if (!fileNames.Exists(delegate(KeyValuePair<string, string> pair) {
							                      	return FileUtility.IsEqualFileName(pair.Key, additionalFile);
							                      }))
							{
								addedDependentFiles = true;
								fileNames.Add(new KeyValuePair<string, string>(additionalFile, Path.GetFileName(fileName)));
							}
						}
					}
					
					
					
					string copiedFileName = Path.Combine(node.Directory, Path.GetFileName(fileNames[0].Key));
					if (!FileUtility.IsEqualFileName(fileNames[0].Key, copiedFileName)) {
						int res = MessageService.ShowCustomDialog(
							fdiag.Title, "${res:ProjectComponent.ContextMenu.AddExistingFiles.Question}",
							0, 2,
							"${res:ProjectComponent.ContextMenu.AddExistingFiles.Copy}",
							"${res:ProjectComponent.ContextMenu.AddExistingFiles.Link}",
							"${res:Global.CancelButtonText}");
						if (res == 1) {
							// Link
							foreach (KeyValuePair<string, string> pair in fileNames) {
								string fileName = pair.Key;
								string relFileName = FileUtility.GetRelativePath(node.Project.Directory, fileName);
								FileNode fileNode = new FileNode(fileName, FileNodeStatus.InProject);
								FileProjectItem fileProjectItem = new FileProjectItem(node.Project, node.Project.GetDefaultItemType(fileName), relFileName);
								fileProjectItem.SetEvaluatedMetadata("Link", Path.Combine(node.RelativePath, Path.GetFileName(fileName)));
								fileProjectItem.DependentUpon = pair.Value;
								addedItems.Add(fileProjectItem);
								fileNode.ProjectItem = fileProjectItem;
								fileNode.InsertSorted(node);
								ProjectService.AddProjectItem(node.Project, fileProjectItem);
							}
							node.Project.Save();
							if (addedDependentFiles)
								node.RecreateSubNodes();
							return addedItems.AsReadOnly();
						}
						if (res == 2) {
							// Cancel
							return addedItems.AsReadOnly();
						}
						// only continue for res==0 (Copy)
					}
					bool replaceAll = false;
					foreach (KeyValuePair<string, string> pair in fileNames) {
						copiedFileName = Path.Combine(node.Directory, Path.GetFileName(pair.Key));
						if (!replaceAll && File.Exists(copiedFileName) && !FileUtility.IsEqualFileName(pair.Key, copiedFileName)) {
							ReplaceExistingFile res = ShowReplaceExistingFileDialog(fdiag.Title, Path.GetFileName(pair.Key), true);
							if (res == ReplaceExistingFile.YesToAll) {
								replaceAll = true;
							} else if (res == ReplaceExistingFile.No) {
								continue;
							} else if (res == ReplaceExistingFile.Cancel) {
								break;
							}
						}
						FileProjectItem item = CopyFile(pair.Key, node, true);
						if (item != null) {
							addedItems.Add(item);
							item.DependentUpon = pair.Value;
						}
					}
					node.Project.Save();
					if (addedDependentFiles)
						node.RecreateSubNodes();
				}
			}
			
//.........这里部分代码省略.........
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:101,代码来源:FolderNodeCommands.cs

示例4: CopyFile

		public static FileProjectItem CopyFile(string fileName, DirectoryNode node, bool includeInProject)
		{
			string copiedFileName = Path.Combine(node.Directory, Path.GetFileName(fileName));
			if (!FileUtility.IsEqualFileName(fileName, copiedFileName)) {
				FileService.CopyFile(fileName, copiedFileName, false, true);
			}
			if (includeInProject) {
				FileNode fileNode;
				foreach (TreeNode childNode in node.AllNodes) {
					if (childNode is FileNode) {
						fileNode = (FileNode)childNode;
						if (FileUtility.IsEqualFileName(fileNode.FileName, copiedFileName)) {
							if (fileNode.FileNodeStatus == FileNodeStatus.Missing) {
								fileNode.FileNodeStatus = FileNodeStatus.InProject;
							} else if (fileNode.FileNodeStatus == FileNodeStatus.None) {
								return IncludeFileInProject.IncludeFileNode(fileNode);
							}
							return fileNode.ProjectItem as FileProjectItem;
						}
					}
				}
				fileNode = new FileNode(copiedFileName);
				fileNode.InsertSorted(node);
				return IncludeFileInProject.IncludeFileNode(fileNode);
			}
			return null;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:27,代码来源:FolderNodeCommands.cs


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