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


C# IWorkspaceFileObject.GetItemFiles方法代码示例

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


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

示例1: Export

		string Export (IProgressMonitor monitor, IWorkspaceFileObject obj, string[] includedChildIds, string targetPath, FileFormat format)
		{
			string rootSourceFile = obj.FileName;
			string sourcePath = Path.GetFullPath (Path.GetDirectoryName (rootSourceFile));
			targetPath = Path.GetFullPath (targetPath);
			
			if (sourcePath != targetPath) {
				if (!CopyFiles (monitor, obj, obj.GetItemFiles (true), targetPath, true))
					return null;
				
				string newFile = Path.Combine (targetPath, Path.GetFileName (rootSourceFile));
				if (IsWorkspaceItemFile (rootSourceFile))
					obj = ReadWorkspaceItem (monitor, newFile);
				else
					obj = (SolutionEntityItem) ReadSolutionItem (monitor, newFile);
				
				using (obj) {
					List<FilePath> oldFiles = obj.GetItemFiles (true);
					ExcludeEntries (obj, includedChildIds);
					if (format != null)
						obj.ConvertToFormat (format, true);
					obj.Save (monitor);
					List<FilePath> newFiles = obj.GetItemFiles (true);
					
					foreach (FilePath f in newFiles) {
						if (!f.IsChildPathOf (targetPath)) {
							if (obj is Solution)
								monitor.ReportError ("The solution '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the root solution directory.", null);
							else
								monitor.ReportError ("The project '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the project directory.", null);
						}
						oldFiles.Remove (f);
					}
	
					// Remove old files
					foreach (FilePath file in oldFiles) {
						if (File.Exists (file)) {
							File.Delete (file);
						
							// Exclude empty directories
							FilePath dir = file.ParentDirectory;
							if (Directory.GetFiles (dir).Length == 0 && Directory.GetDirectories (dir).Length == 0) {
								try {
									Directory.Delete (dir);
								} catch (Exception ex) {
									monitor.ReportError (null, ex);
								}
							}
						}
					}
					return obj.FileName;
				}
			}
			else {
				using (obj) {
					ExcludeEntries (obj, includedChildIds);
					if (format != null)
						obj.ConvertToFormat (format, true);
					obj.Save (monitor);
					return obj.FileName;
				}
			}
		}
开发者ID:hduregger,项目名称:monodevelop,代码行数:63,代码来源:ProjectService.cs

示例2: ConfirmProjectDeleteDialog

		public ConfirmProjectDeleteDialog (IWorkspaceFileObject item)
		{
			this.Build ();
			this.item = item;
			
			store = new TreeStore (typeof(bool), typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string));
			fileList.Model = store;
			
			TreeViewColumn col = new TreeViewColumn ();
			
			CellRendererToggle crt = new CellRendererToggle ();
			crt.Toggled += CrtToggled;
			col.PackStart (crt, false);
			col.AddAttribute (crt, "active", 0);
			
			CellRendererPixbuf crp = new CellRendererPixbuf ();
			col.PackStart (crp, false);
			col.AddAttribute (crp, "pixbuf", 1);
			
			CellRendererText cre = new CellRendererText ();
			col.PackStart (cre, true);
			col.AddAttribute (cre, "text", 2);
			col.AddAttribute (cre, "foreground", 4);
			
			fileList.AppendColumn (col);
			store.SetSortColumnId (2, SortType.Ascending);
			
			labelProjectDir.Text = item.BaseDirectory.FullPath;
			
			HashSet<string> itemFiles = new HashSet<string> ();
			HashSet<string> knownPaths = new HashSet<string> ();
			
			foreach (FilePath file in item.GetItemFiles (true)) {
				itemFiles.Add (file.FullPath);
				knownPaths.Add (file.FullPath + "~");
			}
			
			foreach (string ext in knownExtensions)
				knownPaths.Add (item.FileName.ChangeExtension (ext));

			FillDirRec (TreeIter.Zero, item, itemFiles, knownPaths, item.BaseDirectory, false);
			
			if (item.BaseDirectory != item.ItemDirectory) {
				// If the project has a custom base directory, make sure the project files
				// from the item directory are shown in the list
				foreach (FilePath f in item.GetItemFiles (false)) {
					if (!f.IsChildPathOf (item.BaseDirectory)) {
						Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (f, IconSize.Menu);
						paths [f] = store.AppendValues (true, pix, f.FileName, f.ToString ());
					}
				}
			}

			if (item is SolutionItem) {
				var sol = ((SolutionItem)item).ParentSolution;
				var bdir = item.BaseDirectory;
				if (sol.GetItemFiles (false).Any (f => f.IsChildPathOf (bdir)) || sol.GetAllSolutionItems<SolutionEntityItem> ().Any (it => it != item && it.GetItemFiles (true).Any (f => f.IsChildPathOf (bdir)))) {
					radioDeleteAll.Sensitive = false;
					labelProjectDir.Text = GettextCatalog.GetString ("Project directory can't be deleted since it contains files from other projects or solutions");
				}
			}
			
			if (item.BaseDirectory.FileName == item.Name && radioDeleteAll.Sensitive) {
				radioDeleteAll.Active = true;
				fileList.Sensitive = false;
			}
			else {
				radioDeleteSel.Active = true;
				Focus = radioDeleteSel;
			}
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:71,代码来源:ConfirmProjectDeleteDialog.cs


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