本文整理汇总了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());
}
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
示例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;
}
示例8: IsSourceCodeFile
public bool IsSourceCodeFile(FilePath fileName)
{
return fileName.ToString ().EndsWith (".php", StringComparison.OrdinalIgnoreCase) ||
fileName.ToString ().EndsWith (".phtml", StringComparison.Ordinal);
}
示例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 ("\"", "\\\"")));
}
示例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;
}
示例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);
}
示例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);
}
示例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 ();
}
示例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));
}
示例15: RealEmpty
static FilePath RealEmpty (FilePath filePath)
{
if (filePath.ToString () == ".")
return FilePath.Empty;
return filePath;
}