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


C# FilePath.ToString方法代码示例

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


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

示例1: ValidateFile

        private static void ValidateFile(ICakeContext context, FilePath file) {
            context.Log.Information("Validating \"{0}\"", file.ToString());

            var errors = new Validator(file).Validate();

            if (errors.Any()) {
                foreach (var error in errors) {
                    context.Log.Error("{0}, LineNumber {1}, FileName {2}", error.Message, error.LineNumber,
                        error.FileName);
                }
            }
            else {
                context.Log.Information("Project file \"{0}\" is valid", file.ToString());
            }
        }
开发者ID:RadioSystems,项目名称:Cake.Orchard,代码行数:15,代码来源:ValidateExtensionProjectFiles.cs

示例2: TransformConfig

        public static void TransformConfig(FilePath sourceFile, FilePath transformFile, FilePath targetFile)
        {
            if (sourceFile == null)
            {
                throw new ArgumentNullException(nameof(sourceFile), "Source file path is null.");
            }
            if (transformFile == null)
            {
                throw new ArgumentNullException(nameof(transformFile), "Transform file path is null.");
            }
            if (targetFile == null)
            {
                throw new ArgumentNullException(nameof(targetFile), "Target file path is null.");
            }

            using (var document = new XmlTransformableDocument {PreserveWhitespace = true})
            using (var transform = new XmlTransformation(transformFile.ToString()))
            {
                document.Load(sourceFile.ToString());

                if (!transform.Apply(document))
                {
                    throw new CakeException(
                        string.Format(
                            "Failed to transform \"{0}\" using \"{1}\" to \"{2}\"",
                            sourceFile,
                            transformFile,
                            targetFile
                            )
                        );
                }

                document.Save(targetFile.ToString());
            }
        }
开发者ID:phillipsj,项目名称:Cake.XdtTransform,代码行数:35,代码来源:XdtTransformation.cs

示例3: IsSourceCodeFile

        public bool IsSourceCodeFile(FilePath fileName)
        {
            if(fileName.ToString().EndsWith(".txt", StringComparison.OrdinalIgnoreCase)){
                using(var fs = new StreamReader(fileName)){
                    return fs.ReadLine().Contains("BveTs Map 1.00");
                }
            }

            return false;
        }
开发者ID:hazama-yuinyan,项目名称:monodevelop-bvebinding,代码行数:10,代码来源:BVEMode.cs

示例4: ChangeSet

		internal protected ChangeSet (Repository repo, FilePath basePath)
		{
			this.repo = repo;

			// Make sure the path has a trailing slash or the ChangeLogWriter's
			// call to GetDirectoryName will take us one extra directory up.
			string bp = basePath.ToString ();
			if (bp [bp.Length - 1] != System.IO.Path.DirectorySeparatorChar)
				basePath = bp + System.IO.Path.DirectorySeparatorChar;

			this.basePath = basePath;
		}
开发者ID:llucenic,项目名称:monodevelop,代码行数:12,代码来源:ChangeSet.cs

示例5: ChangeSet

		internal protected ChangeSet (Repository repo, FilePath basePath)
		{
			this.repo = repo;
			
			//make sure the base path has a trailign slash, or ChangeLogWriter's
			//GetDirectoryName call on it will take us up a directory
			string bp = basePath.ToString ();
			if (bp[bp.Length -1] != System.IO.Path.DirectorySeparatorChar)
				basePath = bp + System.IO.Path.DirectorySeparatorChar;
			
			this.basePath = basePath;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:12,代码来源:ChangeSet.cs

示例6: CanCreateVariousPaths

		public void CanCreateVariousPaths ()
		{
			FilePath path;
			string expected;

			expected = Path.Combine ("this", "is", "a", "path");
			path = FilePath.Build ("this", "is", "a", "path");
			Assert.AreEqual (expected, path.ToString ());

			expected = "";
			path = FilePath.Empty;
			Assert.AreEqual (expected, path.ToString ());
			Assert.IsTrue (path.IsEmpty);
			Assert.IsTrue (path.IsNullOrEmpty);

			expected = null;
			path = FilePath.Null;
			Assert.AreEqual (expected, path.ToString ());
			Assert.IsTrue (path.IsNull);
			Assert.IsTrue (path.IsNullOrEmpty);

			expected = Path.Combine ("this", "is", "a", "path");
			path = new FilePath (expected);
			Assert.AreEqual (expected, path.ToString ());

			expected = Path.Combine (expected, "and", "more");
			path = path.Combine ("and", "more");
			Assert.AreEqual (expected, path.ToString ());

			expected = "file.txt";
			path = new FilePath ("file").ChangeExtension (".txt");
			Assert.AreEqual (expected, path.ToString ());

			expected = "file.txt";
			path = new FilePath ("file.type").ChangeExtension (".txt");
			Assert.AreEqual (expected, path.ToString ());

			// TODO: Test file:// scheme
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:39,代码来源:FilePathTests.cs

示例7: CanHandle

		public virtual bool CanHandle (FilePath fileName, string mimeType, Project ownerProject)
		{
			if (excludeThis)
				return false;

			var dprj = ownerProject as AbstractDProject;
			if (dprj == null)
				return false;

			var mod = GlobalParseCache.GetModule (fileName.ToString ());

			if (GetGtkDMainClass (mod) == null)
				return false;

			excludeThis = true;
			var db = DisplayBindingService.GetDefaultViewBinding (fileName, mimeType, ownerProject);
			excludeThis = false;
			return db != null;
		}
开发者ID:DinrusGroup,项目名称:Mono-D,代码行数:19,代码来源:GuiBuilderDisplayBinding.cs

示例8: IsSourceCodeFile

 public bool IsSourceCodeFile(FilePath fileName)
 {
     return fileName.ToString ().EndsWith (".php", StringComparison.OrdinalIgnoreCase) ||
            fileName.ToString ().EndsWith (".phtml", StringComparison.Ordinal);
 }
开发者ID:blindsight,项目名称:phpbinding,代码行数:5,代码来源:PHPLanguageBinding.cs

示例9: OpenInTerminal

		public override void OpenInTerminal (FilePath directory)
		{
			AppleScript.Run (string.Format (
@"tell application ""Terminal""
activate
do script with command ""cd {0}""
end tell", directory.ToString ().Replace ("\"", "\\\"")));
		}
开发者ID:pjt33,项目名称:monodevelop,代码行数:8,代码来源:MacPlatform.cs

示例10: FillDirRec

		ChildInfo FillDirRec (Gtk.TreeIter iter, IWorkspaceFileObject item, HashSet<string> itemFiles, HashSet<string> knownPaths, FilePath dir, bool forceSet)
		{
			ChildInfo cinfo = ChildInfo.AllSelected;
			bool hasChildren = false;
			
			foreach (string sd in knownSubdirs) {
				if (dir == item.BaseDirectory.Combine (sd)) {
					forceSet = true;
					break;
				}
			}
			
			TreeIter dit;
			if (!iter.Equals (TreeIter.Zero)) {
				dit = store.AppendValues (iter, false, DesktopService.GetPixbufForFile (dir, IconSize.Menu), dir.FileName.ToString (), dir.ToString ());
				fileList.ExpandRow (store.GetPath (iter), false);
			}
			else
				dit = store.AppendValues (false, DesktopService.GetPixbufForFile (dir, IconSize.Menu), dir.FileName.ToString (), dir.ToString ());
			
			paths [dir] = dit;
			
			foreach (string file in Directory.GetFiles (dir)) {
				string path = System.IO.Path.GetFileName (file);
				Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (file, IconSize.Menu);
				bool active = itemFiles.Contains (file);
				string color = null;
				if (!active) {
					pix = ImageService.MakeTransparent (pix, 0.5);
					color = "dimgrey";
				} else
					cinfo |= ChildInfo.HasProjectFiles;
				
				active = active || forceSet || knownPaths.Contains (file);
				if (!active)
					cinfo &= ~ChildInfo.AllSelected;
				else
					cinfo |= ChildInfo.SomeSelected;

				paths [file] = store.AppendValues (dit, active, pix, path, file, color);
				if (!hasChildren) {
					hasChildren = true;
					fileList.ExpandRow (store.GetPath (dit), false);
				}
			}
			foreach (string cdir in Directory.GetDirectories (dir)) {
				hasChildren = true;
				ChildInfo ci = FillDirRec (dit, item, itemFiles, knownPaths, cdir, forceSet);
				if ((ci & ChildInfo.AllSelected) == 0)
					cinfo &= ~ChildInfo.AllSelected;
				cinfo |= ci & (ChildInfo.SomeSelected | ChildInfo.HasProjectFiles);
			}
			if ((cinfo & ChildInfo.AllSelected) != 0 && hasChildren)
				store.SetValue (dit, 0, true);
			if ((cinfo & ChildInfo.HasProjectFiles) == 0) {
				Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (dir, IconSize.Menu);
				pix = ImageService.MakeTransparent (pix, 0.5);
				store.SetValue (dit, 1, pix);
				store.SetValue (dit, 4, "dimgrey");
			}
			if ((cinfo & ChildInfo.SomeSelected) != 0 && (cinfo & ChildInfo.AllSelected) == 0) {
				fileList.ExpandRow (store.GetPath (dit), false);
			} else {
				fileList.CollapseRow (store.GetPath (dit));
			}
			return cinfo;
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:67,代码来源:ConfirmProjectDeleteDialog.cs

示例11: AddFile

		void AddFile (FilePath filePath)
		{
			var relativePath = filePath.ToRelative (baseDirectory);
			TreeIter iter = GetPath (relativePath.ParentDirectory);
			object[] values = new object[] {
				//FIXME: look these pixbufs up lazily in the renderer
				DesktopService.GetIconForFile (filePath, IconSize.Menu),
				null,
				filePath.FileName,
				filePath.ToString (),
				false
			};
			if (iter.Equals (TreeIter.Zero)) {
				store.AppendValues (values);
				return;
			}
			store.AppendValues (iter, values);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:18,代码来源:IncludeNewFilesDialog.cs

示例12: FindCommonRoot

		FilePath FindCommonRoot (FilePath p1, FilePath p2)
		{
			string[] s1 = p1.ToString ().Split (Path.DirectorySeparatorChar);
			string[] s2 = p2.ToString ().Split (Path.DirectorySeparatorChar);
			
			int n;
			for (n=0; n<s1.Length && n<s2.Length && s1[n] == s2[n]; n++);
			return string.Join (Path.DirectorySeparatorChar.ToString (), s1, 0, n);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:9,代码来源:CompiledAssemblyProject.cs

示例13: SetConfiguredSdkLocation

		internal static void SetConfiguredSdkLocation (FilePath location)
		{
			if (location.IsNullOrEmpty || location == DefaultRoots.First ())
				location = null;
			if (location == PropertyService.Get<string> (SDK_KEY))
				return;
			PropertyService.Set (SDK_KEY, location.ToString ());

			//if the location is being overridden by an env var, the setting has no effect, so don't bother updating
			if (GetEnvLocation () != null)
				return;

			Init ();
			Changed ();
		}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:15,代码来源:AppleSdkSettings.cs

示例14: SetValue

		public void SetValue (FilePath value, bool relativeToProject = true, FilePath relativeToPath = default(FilePath), bool mergeToMainGroup = false)
		{
			AssertCanModify ();
			MergeToMainGroup = mergeToMainGroup;
			valueType = MSBuildValueType.Path;

			string baseDir = null;
			if (relativeToPath != null) {
				baseDir = relativeToPath;
			} else if (relativeToProject) {
				if (ParentProject == null) {
					// The project has not been set, so we can't calculate the relative path.
					// Store the full path for now, and set the property type to UnresolvedPath.
					// When the property gets a value, the relative path will be calculated
					valueType = MSBuildValueType.UnresolvedPath;
					SetPropertyValue (value.ToString ());
					return;
				}
				baseDir = ParentProject.BaseDirectory;
			}

			// If the path is normalized in the property, keep the value
			if (!string.IsNullOrEmpty (Value) && new FilePath (MSBuildProjectService.FromMSBuildPath (baseDir, Value)).CanonicalPath == value.CanonicalPath)
				return;

			SetPropertyValue (MSBuildProjectService.ToMSBuildPath (baseDir, value, false));
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:27,代码来源:MSBuildProperty.cs

示例15: RealEmpty

		static FilePath RealEmpty (FilePath filePath)
		{
			if (filePath.ToString () == ".")
				return FilePath.Empty;
			return filePath;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:6,代码来源:ProjectFileEntry.cs


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