Ejemplo n.º 1
0
        public void GetFiles()
        {
            var files = Directory.GetFiles(_directory);

            var explorer = new DirectoryExplorer(_directory);
            Assert.That(explorer.GetFiles().Select(x => x.FullName), Is.EqualTo(files));
        }
Ejemplo n.º 2
0
        public void ResearchDirectory_PassedCorrectDirectoryPathWithSpecificExtension_GetSeveralFiles(string extension, int expected)
        {
            var directoryExplorer = new DirectoryExplorer(
                fileInfo => fileInfo.Extension == extension);

            Assert.AreEqual(directoryExplorer.Explore(_testDirectoryPath).Count(), 30);
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            try
            {
                var directoryExplorer = new DirectoryExplorer();

                var notification = new Notification(directoryExplorer);

                notification.SubscribeToEvents();

                Console.WriteLine("Enter start directory path, please-- > ");
                var startDirectory = Console.ReadLine();

                foreach (var entity in directoryExplorer.Explore(startDirectory))
                {
                    Console.WriteLine(entity);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadKey();
        }
Ejemplo n.º 4
0
        public void ResearchDirectory_PassedCorrectDirectoryPathWithSpecificFolderNames_GetSeveralFiles(string folderName, int expected)
        {
            var directoryExplorer = new DirectoryExplorer(
                null, directoryInfo => directoryInfo.Name == folderName);

            Assert.AreEqual(directoryExplorer.Explore(_testDirectoryPath).Count(), expected);
        }
Ejemplo n.º 5
0
        private void btn_GenerateHtmlFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                listBox.Items.Clear();
                if (FolderPath != null && targetFilename != null)
                {
                    Codewatcher_V1_Lib.TreeNode root = DirectoryExplorer.GetFolderStructure(FolderPath);
                    addListboxItems(root);
                    string htmldoc = createHtmlDoc(root, "");
                    SaveTreeInHtmlFile(htmldoc);
                    tblogs.Text = "Successfully generated!";
                }
                else
                {
                    tblogs.Text = "Enter a filename or enter a targetfile!!!";
                }

                foreach (string s in ExceptionList)
                {
                    tblogs.Text += s;
                }
            }
            catch (Exception ex)
            {
                ExceptionList.Add(ex.Message);
            }
        }
Ejemplo n.º 6
0
        public void GetDirectory()
        {
            var directories = Directory.GetDirectories(_directory);

            var explorer = new DirectoryExplorer(_directory);
            Assert.That(explorer.GetDirectories().Select(x => x.FullName), Is.EqualTo(directories));
            Assert.That(explorer.Name, Is.EqualTo("/"));
        }
Ejemplo n.º 7
0
        public override async void Execute(object parameter)
        {
            string query           = m_FindTextViewModel.QueryText;
            string rootPath        = m_FindTextViewModel.RootPathText;
            string extensionFilter = m_FindTextViewModel.FilterText;
            bool   recursive       = m_FindTextViewModel.RecursiveChecked;
            bool   fuzzySearch     = m_FindTextViewModel.FuzzySearchChecked;
            bool   matchCase       = m_FindTextViewModel.MatchCaseChecked;
            bool   copyToClipboard = m_FindTextViewModel.CopyToClipboardChecked;

            //debuggerDataStatusStrip.DropDownItems.Clear();
            m_FindTextViewModel.UpdateStatusBar("Searching...");
            try
            {
                var searchAggregator = new SearchAggregator(query, fuzzySearch, matchCase, copyToClipboard);
                var filepaths        = DirectoryExplorer.GetFilePaths(rootPath, recursive, extensionFilter).ToList();
                var matches          = await searchAggregator.SearchFileSetAsync(filepaths);

                if (UseRelativeFilePaths)
                {
                    foreach (var m in matches)
                    {
                        m.ShortenedPath = m.ShortenedPath.Replace(rootPath, "..");
                    }
                }

                m_FindTextViewModel.MatchList = new ObservableCollection <SearchMatch>(matches);
            }
            catch (DirectoryNotFoundException)
            {
                //There was an issue with the root directory string i.e. the location doesnt exist
                m_FindTextViewModel.UpdateStatusBar("The provided folder path does not exist.", "Red");
                return;
            }
            catch (Exception ex)
            {
#if DEBUG
                //debuggerDataStatusStrip.DropDownItems.Add("Exception: " + ex);
#endif
            }
            finally
            {
#if DEBUG
                //debuggerDataStatusStrip.DropDownItems.Add("Number of files retrieved in all directories: " + m_SearchAggregator.GetFileCount());
#endif
                if (m_FindTextViewModel.MatchList.Count > 0)
                {
                    m_FindTextViewModel.UpdateStatusBar(m_FindTextViewModel.MatchList.Count + " match(es) found.");
                }
                else
                {
                    m_FindTextViewModel.UpdateStatusBar("No matches found.", "Red");
                }
            }
        }
        private void RetrieveExtensions(object parameter)
        {
            var dataGrid = new List <ExtensionCellItem>();

            var extensions = DirectoryExplorer.GetExtensions(m_FolderPath, m_RecursiveChecked).GroupBy(ext => ext).OrderByDescending(ext => ext.Count());

            if (extensions != null && extensions.Any())
            {
                foreach (var extension in extensions)
                {
                    dataGrid.Add(new ExtensionCellItem(extension.Key, extension.Count()));
                }

                ExtensionGrid  = dataGrid;
                HasReturnItems = true;

                ExtensionStateText           = CheckAllExtensionButtonText.CHECK_ALL;
                m_ExtensionSelectionActivity = ExtensionSelectionActivity.CHECK_ALL;
            }
        }
Ejemplo n.º 9
0
 static void Main(string[] args)
 {
     var parser = new Parser(settings =>
     {
         settings.HelpWriter = Console.Error;
         settings.CaseInsensitiveEnumValues = true;
     });
     var result = parser.ParseArguments <Options>(args)
                  .WithParsed <Options>(o =>
     {
         if (DirectoryExplorer.DoesCsProjExistInFolder(o.Path, out var csProjPath))
         {
             ProjectFileParser.ReadFileAndUpdateVersion(csProjPath, o.VersionType);
         }
         else
         {
             Console.WriteLine("No csproj found in directory.");
             Main(new string[] {});
         }
     });
 }
Ejemplo n.º 10
0
 private void btn_GenerateHtmlFile_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         listBox.Items.Clear();
         if (tbSourceFilename != null && targetFilename != null)
         {
             TreeNode root    = DirectoryExplorer.GetFolderStructure(tbSourceFilename.Text);
             string   htmldoc = printTree(root, "");
             SaveTreeInHtmlFile(htmldoc);
             tblogs.Text = "Successfully generated!";
             listBox.Items.Add(root.value);
             AddNestedList(root);
         }
         else
         {
             tblogs.Text = "Enter a filename or enter a targetfile!!!";
         }
     }
     catch (Exception ex)
     {
         tblogs.Text = "Error: " + ex;
     }
 }
Ejemplo n.º 11
0
 private void SelectItemByPath(object sender, RoutedEventArgs e)
 {
     DirectoryExplorer.SelectItemByPath(DirectoryExplorer.SelectedItem?.FullPath);
 }
Ejemplo n.º 12
0
        public void ImportController()
        {
            _bank = AccountFactory.Asset("bank", initialBalance: 100);
            _groceries = AccountFactory.Asset("groceries");
            _wow = AccountFactory.Asset("wow");
            _unclassifiedExpense = AccountFactory.Expense("unclassified");

            _directoryExplorer = new DirectoryExplorer(_directory);
            _repository = new Mock<IImportRepository>();

            _importDetector = new Mock<IImportDetector>(MockBehavior.Strict);
            _generalLedger = new GeneralLedger(new InMemoryRepository())
            {
                _bank,
                _groceries,
                _wow,
                _unclassifiedExpense
            };

            var transactionContext = new TransactionImportContext(_generalLedger, GetAccountIdentifers(), _repository.Object);
            _controller = new ImportController(transactionContext, _directoryExplorer, new ImportDetector(new[] {_importDetector.Object}));
        }
Ejemplo n.º 13
0
 public void NavigateToRoot()
 {
     var explorer = new DirectoryExplorer(_directory);
     Assert.That(explorer.NavigateToRoot(), Is.True);
     Assert.That(explorer.Name, Is.EqualTo("/"));
 }
Ejemplo n.º 14
0
 public void NavigateTo()
 {
     var explorer = new DirectoryExplorer(_directory);
     Assert.That(explorer.NavigateTo("imports/westpac"), Is.True);
     Assert.That(explorer.Name, Is.EqualTo("/Imports/Westpac"));
 }
Ejemplo n.º 15
0
 public void GetFilename()
 {
     var explorer = new DirectoryExplorer(_directory);
     Assert.That(explorer.NavigateTo("imports/westpac"), Is.True);
     Assert.That(explorer.GetFilename("abcd.csv"), Is.EqualTo(Path.Combine(_directory, "Imports\\Westpac", "abcd.csv")));
 }
Ejemplo n.º 16
0
        public void ResearchDirectory_PassedCorrectDirectoryPathWithoutPredicate_GetSeveralFiles()
        {
            var directoryExplorer = new DirectoryExplorer();

            Assert.AreEqual(directoryExplorer.Explore(_testDirectoryPath).Count(), 60);
        }
Ejemplo n.º 17
0
 public DirectoryController()
 {
     DirExplorer = new DirectoryExplorer();
 }
Ejemplo n.º 18
0
 public ImportController(TransactionImportContext transactionImportContext, DirectoryExplorer directoryExplorer, ImportDetector importDetector)
 {
     _transactionImportContext = transactionImportContext;
     _directoryExplorer = directoryExplorer;
     _importDetector = importDetector;
 }
Ejemplo n.º 19
0
 private void ScrollIntoViewAsync(object sender, RoutedEventArgs e)
 {
     DirectoryExplorer.ScrollIntoViewAsync();
 }