Пример #1
0
        public IActionResult Code(CodeToFindViewModel codeToFind)
        {
            var codeFounder = _codeFinderFactory.Create(codeToFind);
            var machingFiles = codeFounder.GetMachingFiles();

            if(! machingFiles.Any())
            {
                return View(new MachingFilesViewModel
                {
                    CodeToFind=codeToFind,
                    NumberOfMatchingFiles = 0,
                    NotFound = true
                });
            }

            var nextFile = 0;
            var bestMatchShortestFileContent =
                _codeProcessor.Process(machingFiles[nextFile++]);

            var matchingFiles = new MachingFilesViewModel
            {
                CodeToFind = codeToFind,
                FirstFileContent = bestMatchShortestFileContent,
                NextFile = nextFile,
                NumberOfMatchingFiles =machingFiles.Length,
                MachingFiles = machingFiles,
            };

            return View(matchingFiles);
        }
Пример #2
0
        public IActionResult Code(CodeToFindViewModel codeToFind)
        {
            var codeFounder  = _codeFinderFactory.Create(codeToFind);
            var machingFiles = codeFounder.GetMachingFiles();

            if (!machingFiles.Any())
            {
                return(View(new MachingFilesViewModel
                {
                    CodeToFind = codeToFind,
                    NumberOfMatchingFiles = 0,
                    NotFound = true
                }));
            }

            var nextFile = 0;
            var bestMatchShortestFileContent =
                _codeProcessor.Process(machingFiles[nextFile++]);

            var matchingFiles = new MachingFilesViewModel
            {
                CodeToFind            = codeToFind,
                FirstFileContent      = bestMatchShortestFileContent,
                NextFile              = nextFile,
                NumberOfMatchingFiles = machingFiles.Length,
                MachingFiles          = machingFiles,
            };

            return(View(matchingFiles));
        }
Пример #3
0
 public ICodeFinder Create(CodeToFindViewModel model)
 {
     var keywords = model.Keywords.Split(',');
     var searchedPath = model.SearchedPath;
     var fileExtensionPattern = model.FileExtensionPattern;
     return new CodeFinder( keywords, searchedPath, fileExtensionPattern);
 }
Пример #4
0
        public ICodeFinder Create(CodeToFindViewModel model)
        {
            var keywords             = model.Keywords.Split(',');
            var searchedPath         = model.SearchedPath;
            var fileExtensionPattern = model.FileExtensionPattern;

            return(new CodeFinder(keywords, searchedPath, fileExtensionPattern));
        }
Пример #5
0
        public IActionResult MatchingFiles(
            [FromForm] CodeToFindViewModel codeToFind)
        {
            if (!ModelState.IsValid)
            {
                return(View(codeToFind));
            }

            return(RedirectToAction("Code", codeToFind));
        }