Exemplo n.º 1
0
        private IEnumerable <IEntity> ExecuteImpl(ExecutionOptions options)
        {
            // determine an optimal search order
            var searchOrder = _priorityComparerFactory.Create(Predicate);
            var files       = EnumeratePaths(options.Progress, options.CancellationToken, searchOrder);

            // execute the query
            using (var reader = _entityManager.CreateReader())
            {
                foreach (var file in files)
                {
                    options.Progress.Report(new QueryProgressReport(ReportType.BeginLoading, file.Path));

                    IEntity entity = null;
                    if (file.IsFile)
                    {
                        entity = LoadEntity(reader, file.Path);
                    }
                    else // file is a directory
                    {
                        entity = new DirectoryEntity(file.Path);
                    }

                    options.Progress.Report(new QueryProgressReport(ReportType.EndLoading, file.Path));

                    if (entity != null && CompiledPredicate(entity))
                    {
                        yield return(entity);
                    }
                }
            }

            options.Progress.Report(new QueryProgressReport(ReportType.EndExecution, null));
        }