public override Verb CreateVerb(string[] tokens) { Color(position, tokens[1].Length, KeyWords); Color(tokens[2].Length, Structures); var index = position + length; var builder = new EnumerationBuilder(); plainParser.Builder = builder; numberParser.Builder = builder; while (true) { if (numberParser.Scan(source, index)) { index = numberParser.Result.Position; continue; } if (plainParser.Scan(source, index)) { index = plainParser.Result.Position; continue; } if (endParser.Scan(source, index)) { overridePosition = endParser.Result.Position; var enumeration = builder.Enumeration(); return(new Push(enumeration)); } break; } return(null); }
public async Task <IList <TransferPath> > SearchLocalSourcePathsAsync(CancellationToken token) { Console2.WriteStartHeader("Search Paths"); string searchLocalPath = Path.Combine(Environment.CurrentDirectory, "Resources"); var paths = new List <TransferPath>(); long totalFileCount = 0; long totalByteCount = 0; var logger = this.CreateTransferLog(); var sourceNode = NodeParser.Node() .WithContext(NullNodeContext.Instance) .WithPath(searchLocalPath) .Parse <IDirectory>(); INode[] sourceNodes = { sourceNode }; var pathEnumerator = EnumerationBuilder.ForUpload(logger, Guid.NewGuid()) .StartFrom(sourceNodes) .WithStatistics(new SynchronousHandler <EnumerationStatistic>( statistic => { totalFileCount = statistic.TotalFiles; totalByteCount = statistic.TotalBytes; })) .Create(); var stopWatch = new Stopwatch(); stopWatch.Start(); await Task.Run(() => { paths.AddRange(pathEnumerator.LazyEnumerate(token) .Select(node => new TransferPath(node.AbsolutePath))); }, token).ConfigureAwait(false); stopWatch.Stop(); this._consolePrinter.DisplaySearchSummary(sourceNode, stopWatch, totalFileCount, totalByteCount); return(paths); }