Beispiel #1
0
        public IObservable <Unit> Save(string file)
        {
            if (Path.GetExtension(file) != ".ttcl")
            {
                file = Path.ChangeExtension(file, ".ttcl");
            }

            MasterDTO masterDTO = new MasterDTO()
            {
                Items         = _itemService.Get().KeyValues.Select(item => new ItemDTO(item.Value)).ToArray(),
                Files         = _fileDataService.Get().KeyValues.Select(file => new FileInfoDTO(file.Value)).ToArray(),
                FileItemLinks = fileItemLinkService.Get().KeyValues.Select(file => new FileItemLinkDTO(file.Value)).ToArray(),
                Directories   = _directoryDataService.Get().KeyValues.Select(dir => new DirectorySetupDTO(dir.Value))
            };
            FileStream fs  = File.Create(file);
            var        res = JsonSerializer
                             .SerializeAsync(fs, masterDTO)
                             .ToObservable()
                             .Take(1)
                             .Catch((Exception ex) =>
            {
                MessageBox.Show(ex.ToString(), $"{nameof(SaveService)}.{nameof(Save)}:Catch");
                return(Observable.Return(new Unit()));
            })
                             .Finally(() => fs.Dispose());

            res.Subscribe();
            return(res);
        }
Beispiel #2
0
 public RemoveDirectorySetupRecursivelyCommand(ILibraryManagementService libraryManagementService, IDirectoryDataService directoryDataService)
 {
     this.libraryManagementService = libraryManagementService;
     this.directoryDataService     = directoryDataService;
     directoryDataService
     .Get()
     .Connect()
     .TakeUntil(destroy)
     .ObserveOn(RxApp.MainThreadScheduler)
     .Subscribe(_ =>
     {
         this.CanExecuteChanged?.Invoke(this, new EventArgs());
     });
 }