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


C# Path.First方法代码示例

本文整理汇总了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));
        }
开发者ID:rvdginste,项目名称:openfilesystem,代码行数:15,代码来源:InMemoryFileSystem.cs

示例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());
 }
开发者ID:rvdginste,项目名称:openfilesystem,代码行数:10,代码来源:InMemoryFileSystem.cs

示例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)));
        }
开发者ID:SolomonBier,项目名称:streamvis,代码行数:6,代码来源:RosArray.cs

示例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;
            }
        }
开发者ID:guylangston,项目名称:SokoSolve,代码行数:69,代码来源:MouseController.cs

示例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));
        }
开发者ID:openrasta,项目名称:openfilesystem,代码行数:24,代码来源:InMemoryFileSystem.cs


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