本文整理汇总了C#中Path.First方法的典型用法代码示例。如果您正苦于以下问题:C# Path.First方法的具体用法?C# Path.First怎么用?C# Path.First使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.First方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDirectory
public IDirectory GetDirectory(string directoryPath)
{
directoryPath = EnsureTerminatedByDirectorySeparator(directoryPath);
var resolvedDirectoryPath = System.IO.Path.GetFullPath(System.IO.Path.Combine(CurrentDirectory,directoryPath));
var path = new Path(resolvedDirectoryPath);
var pathSegments = new Path(resolvedDirectoryPath).Segments;
var root = pathSegments.First();
return pathSegments
.Skip(1)
.Aggregate((IDirectory)GetRoot(path.IsUnc ? string.Format("{0}{0}{1}", System.IO.Path.DirectorySeparatorChar, root) : root),
(current, segment) => current.GetDirectory(segment));
}
示例2: GetFile
public IFile GetFile(string filePath)
{
var resolvedFilePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(CurrentDirectory, filePath));
var pathSegments = new Path(resolvedFilePath).Segments;
var ownerFolder = pathSegments
.Skip(1).Take(pathSegments.Count()-2)
.Aggregate((IDirectory)GetRoot(pathSegments.First()),
(current, segment) => current.GetDirectory(segment));
return ownerFolder.GetFile(pathSegments.Last());
}
示例3: GetName
public override string GetName(Path path)
{
if (!path.Any()) throw new ArgumentException("Parameter 'path' cannot be empty.");
return "[" + path.First() + "]" + type.GetName(new Path(path.Skip(1)));
}
示例4: UpdateMouseWithLogicalCell
public void UpdateMouseWithLogicalCell(VectorInt2 cell, bool isLeftDown, bool isRightDown)
{
if (!Game.Current.Contains(cell)) return;
peekMovePath = null;
peekCratePath = null;
try
{
if (Game.HasPendingMoves)
{
// No hints while there are outstanding actions
return;
}
if (isLeftDown && !prevLeftDown)
{
Drag(cell);
return;
}
if (!isLeftDown && prevLeftDown)
{
Drop(cell);
return;
}
var peek = Peek(cell);
if (peek != Action.None)
{
if (peek == Action.Move)
{
start = Game.Current.Player.Position;
var end = cell;
var boundry = Game.Current.ToMap(Game.Current.Definition.Wall, Game.Current.Definition.Crate,
Game.Current.Definition.CrateGoal);
peekMovePath = PathFinder.Find(boundry, start, end);
}
else if (peek == Action.Drag)
{
var end = cell;
var state = Game.Analysis.Evalute(Game.Current);
var pushMap = PushMap.Find(state.Static, state.Current, start, Game.Current.Player.Position);
if (pushMap.CrateMap[end])
{
//var walk = pushMap.FindPlayerWalkRoute(end);
peekCratePath = pushMap.FindCrateRoute(end);
// PLayer move to begin crate stuff
var pstart = Game.Current.Player.Position;
var pend = start - peekCratePath.First();
var boundry = Game.Current.ToMap(Game.Current.Definition.Wall, Game.Current.Definition.Crate,
Game.Current.Definition.CrateGoal);
peekMovePath = PathFinder.Find(boundry, pstart, pend);
if (peekMovePath != null)
{
peekMovePath.Add(peekCratePath.First());
}
}
}
}
}
finally
{
prev = cell;
prevLeftDown = isLeftDown;
prevRightDown = isRightDown;
}
}
示例5: GetDirectory
public IDirectory GetDirectory(string directoryPath)
{
directoryPath = EnsureTerminatedByDirectorySeparator(directoryPath);
var resolvedDirectoryPath = System.IO.Path.GetFullPath(System.IO.Path.Combine(CurrentDirectory,directoryPath));
var path = new Path(resolvedDirectoryPath);
var rootPath = System.IO.Path.GetPathRoot(path);
if (!path.IsUnc &&
rootPath.Length > 0 &&
(rootPath[rootPath.Length-1] == System.IO.Path.DirectorySeparatorChar ||
rootPath[rootPath.Length-1] == System.IO.Path.AltDirectorySeparatorChar))
rootPath = rootPath.Substring(0,rootPath.Length - 1);
var root = GetRoot(rootPath);
IEnumerable<string> pathSegments = new Path(resolvedDirectoryPath).Segments;
if (path.IsUnc || rootPath == pathSegments.First())
pathSegments = pathSegments.Skip(1);
return pathSegments
.Aggregate(root,
(current, segment) => current.GetDirectory(segment));
}