Ejemplo n.º 1
0
        private void ProcessDirectory(string directoryPath, ISpecification <NodeModelBase> specification,
                                      INodeFoundEventPublisher recursiveSearchResult)
        {
            var model = _directoryService.GetDirectory(directoryPath);

            if (specification.IsSatisfiedBy(model))
            {
                recursiveSearchResult.RaiseNodeFoundEvent(directoryPath);
            }
        }
Ejemplo n.º 2
0
    private static void ProcessNode(string nodePath, ISpecification <NodeModelBase> specification,
                                    INodeFoundEventPublisher publisher, Func <string, NodeModelBase> factory)
    {
        var model = factory(nodePath);

        if (specification.IsSatisfiedBy(model))
        {
            publisher.RaiseNodeFoundEvent(nodePath);
        }
    }
Ejemplo n.º 3
0
        private void ProcessFile(string filePath, ISpecification <NodeModelBase> specification,
                                 INodeFoundEventPublisher publisher)
        {
            var model = _fileService.GetFile(filePath);

            if (specification.IsSatisfiedBy(model))
            {
                publisher.RaiseNodeFoundEvent(filePath);
            }
        }
Ejemplo n.º 4
0
 private void ProcessNodes(string directory, ISpecification <NodeModelBase> specification,
                           INodeFoundEventPublisher publisher)
 {
     foreach (var node in _directoryService.GetNodesRecursively(directory))
     {
         try
         {
             if (_fileService.CheckIfExists(node))
             {
                 ProcessFile(node, specification, publisher);
             }
             else
             {
                 ProcessDirectory(node, specification, publisher);
             }
         }
         catch (Exception ex)
         {
             _logger.LogError(ex, "Exception occurred during recursive search");
         }
     }
 }
Ejemplo n.º 5
0
 private void ProcessDirectory(string directoryPath, ISpecification <NodeModelBase> specification,
                               INodeFoundEventPublisher publisher) =>
 ProcessNode(directoryPath, specification, publisher, _directoryService.GetDirectory);
Ejemplo n.º 6
0
 private void ProcessFile(string filePath, ISpecification <NodeModelBase> specification,
                          INodeFoundEventPublisher publisher) =>
 ProcessNode(filePath, specification, publisher, _fileService.GetFile);
 static Task TaskFactory(INodeFoundEventPublisher r) => Task.CompletedTask;