示例#1
0
文件: Tree.cs 项目: kiple/gitter
        public static async Task <Tree> GetAsync(Repository repository, string treeHash, IProgress <OperationProgress> progress, CancellationToken cancellationToken)
        {
            Verify.Argument.IsNotNull(repository, nameof(repository));

            progress?.Report(new OperationProgress(Resources.StrsFetchingTree.AddEllipsis()));
            var parameters = new QueryTreeContentParameters(treeHash, true, false);
            var treeData   = await repository.Accessor.QueryTreeContent.InvokeAsync(parameters, progress, cancellationToken);

            var tree = new Tree(repository, treeHash, false);

            tree.SetContent(treeData);
            return(tree);
            //return repository.Accessor.QueryTreeContent.InvokeAsync(parameters, progress, cancellationToken)
            //	.ContinueWith(
            //	t =>
            //	{
            //		var treeData = TaskUtility.UnwrapResult(t);
            //		var tree = new Tree(repository, treeHash, false);
            //		tree.SetContent(treeData);
            //		return tree;
            //	},
            //	cancellationToken,
            //	TaskContinuationOptions.ExecuteSynchronously,
            //	TaskScheduler.Default);
        }
示例#2
0
        public static Task <Tree> GetAsync(Repository repository, string treeHash, IProgress <OperationProgress> progress, CancellationToken cancellationToken)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            if (progress != null)
            {
                progress.Report(new OperationProgress(Resources.StrsFetchingTree.AddEllipsis()));
            }
            var parameters = new QueryTreeContentParameters(treeHash, true, false);

            return(repository.Accessor.QueryTreeContent.InvokeAsync(parameters, progress, cancellationToken)
                   .ContinueWith(
                       t =>
            {
                var treeData = TaskUtility.UnwrapResult(t);
                var tree = new Tree(repository, treeHash, false);
                tree.SetContent(treeData);
                return tree;
            },
                       cancellationToken,
                       TaskContinuationOptions.ExecuteSynchronously,
                       TaskScheduler.Default));
        }
示例#3
0
        public Command GetQueryTreeContentCommand(QueryTreeContentParameters parameters)
        {
            Assert.IsNotNull(parameters);

            var args = new List<ICommandArgument>();
            if(parameters.OnlyTrees)
            {
                args.Add(LsTreeCommand.Directories());
            }
            if(parameters.Recurse)
            {
                args.Add(LsTreeCommand.Recurse());
            }
            args.Add(LsTreeCommand.Tree());
            args.Add(LsTreeCommand.FullName());
            args.Add(LsTreeCommand.Long());
            args.Add(LsTreeCommand.NullTerminate());
            args.Add(new CommandParameter(parameters.TreeId));
            if(parameters.Paths != null)
            {
                foreach(var path in parameters.Paths)
                {
                    args.Add(new PathCommandArgument(path));
                }
            }
            return new LsTreeCommand(args);
        }