public ConsoleApplication(IConsoleApplicationSettings consoleApplicationSettings, IFileSystemTextManipulator manipulator) { if (manipulator == null) throw new ArgumentNullException("manipulator"); _fileSystemTextManipulator = manipulator; _textReader = consoleApplicationSettings.Reader; _textWriter = consoleApplicationSettings.Writer; _commands = new Dictionary<string, Action<string>> { {"cd", Cd}, {"delete", Delete}, {"exists", Exists}, {"exit", Exit}, {"export", Export}, {"help", ShowHelp}, {"import", Import}, {"ls", List}, {"mkdir", Mkdir}, }; _shouldAbort = () => false; _operationCompleted = success => _textWriter.WriteLine("operation completed"); _totalToProcessChanged = i => _textWriter.WriteLine("total to process: {0}", i); _currentlyProcessedChanged = i => _textWriter.WriteLine("total to process: {0}", i); }
public SearchService(IFileSystemTextManipulator manipulator, ReaderWriterLockSlim readerWriterLock) { _lock = readerWriterLock; _manipulator = manipulator; _indexService = new IndexService(); }
public SynchronizationViewModel(IFileSystemTextManipulator manipulator, UserDto user, Action synchronizationFinished) { _service = manipulator.GenerateSynchronizationService( user, new SynchronizationCallbacks(synchronizationFinished, SynchronizationProgrssChanged)); ; _dlg = new SynchronizationDialog(this); _dlg.Hide(); InitSynchronizationTimer(); }
public DiskInfoViewModel(IFileSystemTextManipulator manipulator) { if (manipulator == null) throw new ArgumentNullException("manipulator"); _manipulator = manipulator; _filePath = _manipulator.FileSystemOptions.Location; _freeDiskSpace = String.Format("{0:0,0} Bytes", _manipulator.FileSystemOptions.DiskFree); _freeDiskSpaceGb = String.Format("{0:0.000} GB", _manipulator.FileSystemOptions.DiskFree / 1024.0 / 1024.0 / 1024.0); _occupiedDiskSpace = String.Format("{0:0,0} Bytes", _manipulator.FileSystemOptions.DiskOccupied); _occupiedDiskSpaceGb = String.Format("{0:0.000} GB", _manipulator.FileSystemOptions.DiskOccupied / 1024.0 / 1024.0 / 1024.0); _version = String.Format ("{0}", _manipulator.LatestVersion); }
private static void ImportFile(string testFileSource, string internalTestfilePath, string testFileData, IFileSystemTextManipulator m) { if (File.Exists(testFileSource)) File.Delete(testFileSource); File.WriteAllText(testFileSource, testFileData); m.Import(testFileSource, internalTestfilePath); }
private static void AssertExportThrowsException(IFileSystemTextManipulator m, string testFileSource, int version) { try { m.Export(testFileSource, testFileSource, null, version); Assert.Fail("Should throw exception"); } catch (VFSException) { // Pass } }
private void Dispose(bool disposing) { if (!disposing) return; // free managed resources if (_fileSystemTextManipulator != null) { _fileSystemTextManipulator.Dispose(); _fileSystemTextManipulator = null; } }
private void OpenVfsWithPassword(string fileName) { var passwordDialog = new PasswordDialogViewModel(); if (passwordDialog.ShowDialog() != true) return; try { var manipulator = _container.Resolve<IFileSystemTextManipulatorFactory>().Open(fileName, passwordDialog.Password); // Close last vfs DisposeManipulator(); if (_manipulator != null) _manipulator.FileSystemChanged -= FileSystemChanged; _manipulator = manipulator; _manipulator.FileSystemChanged += FileSystemChanged; CurrentPath = new DirectoryPath(); OnPropertyChanged("FileSystemName"); } catch (Exception ex) { UserMessage.Exception(ex); } UpdateVersion(); }
private void NewVfs(object parameter) { var pathToVFS = ViewModelHelper.ChoosePlaceForNewVFSFile(); if (pathToVFS == null) return; // Close last vfs DisposeManipulator(); var vm = new NewVFSViewModel(); if (vm.ShowDialog() != true) return; try { var fileSystemData = new FileSystemOptions(pathToVFS, vm.EncryptionType, vm.CompressionType); _manipulator = _container.Resolve<IFileSystemTextManipulatorFactory>().Create(fileSystemData, vm.Password); _manipulator.FileSystemChanged += FileSystemChanged; CurrentPath = new DirectoryPath(); OnPropertyChanged("FileSystemName"); } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } UpdateVersion(); }
private void CloseVfs(object parameter) { SwitchToOfflineMode(null); SwitchToLatestVersion(null); // Close last vfs _manipulator.FileSystemChanged -= FileSystemChanged; DisposeManipulator(); _manipulator = null; Items.Clear(); OnPropertyChanged("FileSystemName"); }