コード例 #1
0
        public void UpdateNavigationSettings(INavigationService navigationService, Settings settings)
        {
            if (navigationService == null)
            {
                throw new ArgumentNullException("navigationService");
            }

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            INavigatorManager primaryNavigatorManager = CreateNavigatorManager(settings.PrimaryNavigator, settings);
            List<INavigatorManager> supportedNavigatorManagers = CreateSupportedNavigatorManagers(settings, primaryNavigatorManager);

            navigationService.PrimaryNavigatorManager = primaryNavigatorManager;
            navigationService.SupportedNavigatorManagers = supportedNavigatorManagers;

            CachedFileSystemParser parser = navigationService.FileSystemParser as CachedFileSystemParser;
            if (parser != null)
            {
                parser.ExcludeFolderTemplates = settings.ExcludeFolderTemplates;
                parser.FoldersToParse = settings.FoldersToParse;
            }

            //Warming up (to fill caches, etc)
            navigationService.GetFolderMatches("temp");
        }
コード例 #2
0
 private static INavigatorManager CreateNavigatorManager(Navigators navigator, Settings settings)
 {
     if (navigator == Navigators.TotalCommander)
     {
         return new TotalCommanderManager(settings.TotalCommanderPath);
     }
     else
     {
         return new WindowsExplorerManager();
     }
 }
        public void UpdateNavigationSettings_SettingsPrimaryNavigatorIsTotalCommander_ServicePrimaryNavigatorIsTotalCommander()
        {
            Settings settings = new Settings
                                    {
                                        PrimaryNavigator = Navigators.TotalCommander,
                                        SupportedNavigators = new List<Navigators>(),
                                        TotalCommanderPath = "TotalCmd.exe"
                                    };
            _navigationServiceBuilder.UpdateNavigationSettings(_service, settings);

            Assert.That(_service.PrimaryNavigatorManager.GetType(), Is.EqualTo(typeof(TotalCommanderManager)));
        }
        public void UpdateNavigationSettings_SettingsIncludeWindowsExplorer_ServiceSupportsWindowsExplorer()
        {
            Settings settings = new Settings
                                    {
                                        SupportedNavigators = new List<Navigators> { Navigators.WindowsExplorer },
                                        PrimaryNavigator = Navigators.WindowsExplorer
                                    };
            _navigationServiceBuilder.UpdateNavigationSettings(_service, settings);

            List<Type> navigatorTypes = _service.SupportedNavigatorManagers.Select(m => m.GetType()).ToList();
            Assert.That(navigatorTypes, Is.EquivalentTo(new List<Type> { typeof(WindowsExplorerManager) }));
        }
コード例 #5
0
        public void Deserialize_AfterRunOnStartUpChangedInRegistry_ReturnUpdatedValue()
        {
            Settings expectedSettings = new Settings
            {
                RunOnStartup = true
            };
            _settingsSerializer.Serialize(expectedSettings);

            _registryService.RunOnStartUp = false;
            Settings actualSettings = _settingsSerializer.Deserialize();

            Assert.That(actualSettings.RunOnStartup, Is.False);
        }
        public void UpdateNavigationSettings_SettingsDoNotSupportTotalCommander_TotalCommanderRemoved()
        {
            _service.SupportedNavigatorManagers = new List<INavigatorManager> { new TotalCommanderManager("TotalCmd.exe") };
            Settings settings = new Settings
                                    {
                                        SupportedNavigators = new List<Navigators> { Navigators.WindowsExplorer },
                                        TotalCommanderPath = "TotalCmd.exe",
                                        PrimaryNavigator = Navigators.WindowsExplorer
                                    };
            _navigationServiceBuilder.UpdateNavigationSettings(_service, settings);

            List<Type> navigatorTypes = _service.SupportedNavigatorManagers.Select(m => m.GetType()).ToList();
            Assert.That(navigatorTypes, Is.EquivalentTo(new List<Type> { typeof(WindowsExplorerManager) }));
        }
コード例 #7
0
        public INavigationService BuildNavigationService(Settings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            IFileSystemParser parser = CreateParser(settings);

            INavigatorManager primaryNavigatorManager = CreateNavigatorManager(settings.PrimaryNavigator, settings);
            List<INavigatorManager> supportedNavigatorManagers = CreateSupportedNavigatorManagers(settings, primaryNavigatorManager);

            INavigationService navigationAssistant = new NavigationService(parser,
                                                                           new MatchSearcher(),
                                                                           primaryNavigatorManager,
                                                                           supportedNavigatorManagers);

            //Warming up (to fill caches, etc)
            navigationAssistant.GetFolderMatches("temp");

            return navigationAssistant;
        }
コード例 #8
0
        public void Deserialize_AfterSerialization_SettingsCorrect()
        {
            File.WriteAllText(TotalCommanderPath, string.Empty);
            Settings expectedSettings = new Settings
                                            {
                                                PrimaryNavigator = Navigators.TotalCommander,
                                                SupportedNavigators = new List<Navigators> {Navigators.TotalCommander},
                                                TotalCommanderPath = TotalCommanderPath,
                                                FoldersToParse = new List<string> {"D:\\temp"},
                                                ExcludeFolderTemplates = new List<string> {"obj", "svn"},
                                                GlobalKeyCombination = Keys.Shift | Keys.M
                                            };
            _settingsSerializer.Serialize(expectedSettings);

            Settings actualSettings = _settingsSerializer.Deserialize();

            Assert.That(actualSettings.PrimaryNavigator, Is.EqualTo(expectedSettings.PrimaryNavigator));
            Assert.That(actualSettings.SupportedNavigators, Is.EquivalentTo(expectedSettings.SupportedNavigators));
            Assert.That(actualSettings.TotalCommanderPath, Is.EqualTo(expectedSettings.TotalCommanderPath));
            Assert.That(actualSettings.FoldersToParse, Is.EquivalentTo(expectedSettings.FoldersToParse));
            Assert.That(actualSettings.ExcludeFolderTemplates, Is.EquivalentTo(expectedSettings.ExcludeFolderTemplates));
            Assert.That(actualSettings.GlobalKeyCombination, Is.EqualTo(expectedSettings.GlobalKeyCombination));
        }
コード例 #9
0
        private static List<INavigatorManager> CreateSupportedNavigatorManagers(Settings settings, INavigatorManager primaryNavigatorManager)
        {
            List<Navigators> additionalNavigators = new List<Navigators>(settings.SupportedNavigators);
            additionalNavigators.Remove(settings.PrimaryNavigator);

            List<INavigatorManager> supportedNavigatorManagers =
                additionalNavigators
                    .Select(navigator => CreateNavigatorManager(navigator, settings))
                    .ToList();

            supportedNavigatorManagers.Add(primaryNavigatorManager);

            return supportedNavigatorManagers;
        }
コード例 #10
0
        public void Serialize_FolderAndFileDontExist_FolderAndFileCreated()
        {
            Settings settings = new Settings { SupportedNavigators = new List<Navigators>() };
            ValidationResult result = _settingsSerializer.Serialize(settings);

            Assert.That(File.Exists(SettingsFilePath), Is.True);
            Assert.That(result.IsValid, Is.True);
        }
コード例 #11
0
 private void HandleCancelButtonClick(object sender, RoutedEventArgs e)
 {
     Hide();
     CurrentSettings = _initialSettings;
 }
コード例 #12
0
        public void UpdateSettings(Settings settings)
        {
            lock (_syncObject)
            {
                _view.CurrentSettings = settings;

                _keyboardListener.StopListening();
                _keyboardListener.StartListening(settings.GlobalKeyCombination);

                if (_navigationAssistant != null)
                {
                    //This code will not be called, if _navigationServiceBuilder is used in the
                    //Initialize function; so we don't need to synchronize _navigationServiceBuilder additionally.
                    _navigationServiceBuilder.UpdateNavigationSettings(_navigationAssistant, settings);
                }
            }
        }
コード例 #13
0
        private IFileSystemParser CreateParser(Settings settings)
        {
            //Don't use the same file system parser for cachedParser and AsyncFileSystemParser,
            //as AsyncFileSystemParser will operate on a different thread.
            IFileSystemParser basicParser = new FileSystemParser(new FileSystemListener());
            ICacheSerializer cacheSerializer = new CacheSerializer();
            IFileSystemParser cachedParser = new CachedFileSystemParser(basicParser,
                                                                        cacheSerializer,
                                                                        new FileSystemListener(),
                                                                        new RegistryService(),
                                                                        new AsyncFileSystemParser(new FileSystemParser(new FileSystemListener())),
                                                                        _appRunOnStartup);

            cachedParser.ExcludeFolderTemplates = settings.ExcludeFolderTemplates;
            cachedParser.FoldersToParse = settings.FoldersToParse;

            return cachedParser;
        }
コード例 #14
0
        public void Deserialize_TotalCommanderDoesntExistRegistryPathDoesntExists_ReturnNull()
        {
            File.WriteAllText(TotalCommanderPath, string.Empty);
            Settings expectedSettings = new Settings
            {
                TotalCommanderPath = TotalCommanderPath
            };
            _settingsSerializer.Serialize(expectedSettings);

            File.Delete(TotalCommanderPath);

            const string currentTotalCmdFolder = TempFolder + "\\TotalCmd";
            const string currentTotalCmdPath = currentTotalCmdFolder + "\\TotalCmd\\TOTALCMD.EXE";
            _registryService.TotalCommanderFolder = currentTotalCmdPath;

            Settings actualSettings = _settingsSerializer.Deserialize();

            Assert.That(actualSettings.TotalCommanderPath, Is.Null);
        }
コード例 #15
0
        public void Serialize_SupportTotalCommanderTotalCommanderExists_SaveCorrectly()
        {
            File.WriteAllText(TotalCommanderPath, string.Empty);
            Settings settings = new Settings
                                    {
                                        SupportedNavigators = new List<Navigators> { Navigators.TotalCommander },
                                        TotalCommanderPath = TotalCommanderPath
                                    };
            ValidationResult result = _settingsSerializer.Serialize(settings);

            Assert.That(File.Exists(SettingsFilePath), Is.True);
            Assert.That(result.IsValid, Is.True);
        }
コード例 #16
0
        public void Serialize_SupportTotalCommanderTotalCommanderEmpty_ReturnValidationError()
        {
            Settings settings = new Settings
                                    {
                                        SupportedNavigators = new List<Navigators> {Navigators.TotalCommander}
                                    };
            ValidationResult result = _settingsSerializer.Serialize(settings);

            Assert.That(result.IsValid, Is.False);
            Assert.That(File.Exists(SettingsFilePath), Is.False);
        }
コード例 #17
0
        public void Serialize_SupportTotalCommanderTotalCommanderDoesntExist_ReturnValidationError()
        {
            Settings settings = new Settings
                                    {
                                        SupportedNavigators = new List<Navigators> {Navigators.TotalCommander},
                                        TotalCommanderPath = TotalCommanderPath
                                    };
            ValidationResult result = _settingsSerializer.Serialize(settings);

            Assert.That(result.IsValid, Is.False);
            Assert.That(result.ErrorKeys, Is.EquivalentTo(new List<string> { "TotalCommanderPathInvalidError" }));
            Assert.That(File.Exists(SettingsFilePath), Is.False);
        }
        public void UpdateNavigationSettings_SettingsPrimaryNavigatorIsWindowsExplorer_ServicePrimaryNavigatorIsWindowsExplorer()
        {
            Settings settings = new Settings
                                    {
                                        PrimaryNavigator = Navigators.WindowsExplorer,
                                        SupportedNavigators = new List<Navigators>(),
                                    };
            _navigationServiceBuilder.UpdateNavigationSettings(_service, settings);

            Assert.That(_service.PrimaryNavigatorManager.GetType(), Is.EqualTo(typeof(WindowsExplorerManager)));
        }
        public void UpdateNavigationSettings_SettingsSupportTotalCommanderAndPrimaryNavigatorIsWindowsExplorer_ServiceSupportsTotalCommanderAndWindowsExplorer()
        {
            Settings settings = new Settings
            {
                SupportedNavigators = new List<Navigators> { Navigators.TotalCommander },
                PrimaryNavigator = Navigators.WindowsExplorer,
                TotalCommanderPath = "TotalCmd.exe"
            };
            _navigationServiceBuilder.UpdateNavigationSettings(_service, settings);

            List<Type> navigatorTypes = _service.SupportedNavigatorManagers.Select(m => m.GetType()).ToList();
            Assert.That(navigatorTypes, Is.EquivalentTo(new List<Type> { typeof(TotalCommanderManager), typeof(WindowsExplorerManager) }));
        }
コード例 #20
0
 public void UpdateSettings(Settings settings)
 {
     _view.CurrentSettings = settings;
 }
コード例 #21
0
 private INavigationService Initialize(Settings settings)
 {
     //Should not lock this operation, as otherwise all other methods will be locked.
     //_navigationServiceBuilder can not be used anywhere else.
     return _navigationServiceBuilder.BuildNavigationService(settings);
 }
コード例 #22
0
        public void Serialize_DontSupportTotalCommanderTotalCommanderEmpty_SaveCorrectly()
        {
            Settings settings = new Settings { SupportedNavigators = new List<Navigators>() };
            ValidationResult result = _settingsSerializer.Serialize(settings);

            Assert.That(File.Exists(SettingsFilePath), Is.True);
            Assert.That(result.IsValid, Is.True);
        }
コード例 #23
0
        private void HandleClosing(object sender, CancelEventArgs e)
        {
            if (_isDisposing)
            {
                return;
            }

            Hide();
            CurrentSettings = _initialSettings;
            e.Cancel = true;
        }
コード例 #24
0
        public void Serialize_ExcludeFolderTemplatesNotValid_ReturnValidationError()
        {
            Settings settings = new Settings
                                    {
                                        ExcludeFolderTemplates = new List<string> {"svn", "["}
                                    };
            ValidationResult result = _settingsSerializer.Serialize(settings);

            Assert.That(result.IsValid, Is.False);
            Assert.That(result.ErrorKeys, Is.EquivalentTo(new List<string> { "ExcludeFolderTemplatesInvalidError" }));
            Assert.That(File.Exists(SettingsFilePath), Is.False);
        }
コード例 #25
0
        public object Clone()
        {
            Settings clone = new Settings();

            clone.PrimaryNavigator = PrimaryNavigator;
            clone.SupportedNavigators = SupportedNavigators;
            clone.TotalCommanderPath = TotalCommanderPath;
            clone.FoldersToParse = FoldersToParse;
            clone.ExcludeFolderTemplates = ExcludeFolderTemplates;
            clone.GlobalKeyCombination = GlobalKeyCombination;
            clone.RunOnStartup = RunOnStartup;

            return clone;
        }
コード例 #26
0
        public void Deserialize_TotalCommanderEmptyRegistryPathExists_ReturnPathFromRegistry()
        {
            Settings expectedSettings = new Settings();
            _settingsSerializer.Serialize(expectedSettings);

            const string currentTotalCmdFolder = TempFolder + "\\TotalCmd";
            const string currentTotalCmdPath = currentTotalCmdFolder + "\\TOTALCMD.EXE";
            _registryService.TotalCommanderFolder = currentTotalCmdFolder;

            DirectoryUtility.EnsureClearFolder(currentTotalCmdFolder);
            File.WriteAllText(currentTotalCmdPath, string.Empty);

            Settings actualSettings = _settingsSerializer.Deserialize();

            Assert.That(actualSettings.TotalCommanderPath, Is.EqualTo(currentTotalCmdPath));
        }