public async Task LoadSettingsAsync() { var settingsFile = await _store.ParseAsync(_fileName); if (settingsFile != null) { XmlSerializer serializer = new XmlSerializer(typeof(BookmarkModel)); using (var stream = await _store.DiskIO.OpenStreamAsync(settingsFile, FileAccess.Read, CancellationToken.None)) { BookmarkModel bm = serializer.Deserialize(stream) as BookmarkModel; bm.Profile = this; _rootModel = bm; } await RefreshAllBookmarksAsync(); } }
public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm) { string fileName = _fileNameGenerator.Generate(); while (fileName != null && await _profile.ParseAsync(_profile.Path.Combine(_parentPath, fileName)) != null) { fileName = _fileNameGenerator.Generate(); } if (fileName == null) { return(ResultCommand.Error(new ArgumentException("Already exists."))); } string newEntryPath = _profile.Path.Combine(_parentPath, fileName); var createddModel = await _profile.DiskIO.CreateAsync(newEntryPath, _isFolder, pm.CancellationToken); return(new NotifyChangedCommand(_profile, newEntryPath, FileExplorer.Defines.ChangeType.Created, _thenFunc(createddModel))); }
public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm) { string path = pm.ReplaceVariableInsideBracketed(PathKey); if (path == null) { return(ResultCommand.Error(new ArgumentException("Path not specified."))); } IDiskProfile profile = pm.GetValue <IDiskProfile>(ProfileKey); if (profile == null) { return(ResultCommand.Error(new ArgumentException(ProfileKey + " is not assigned or not IDiskProfile."))); } string parentPath = profile.Path.GetDirectoryName(path); IFileNameGenerator fNameGenerator = FileNameGenerator.FromNameGenerationMode(NameGenerationMode, profile.Path.GetFileName(path)); string fileName = fNameGenerator.Generate(); while (fileName != null && await profile.ParseAsync(profile.Path.Combine(parentPath, fileName)) != null) { fileName = fNameGenerator.Generate(); } if (fileName == null) { return(ResultCommand.Error(new ArgumentException("Already exists."))); } string newEntryPath = profile.Path.Combine(parentPath, fileName); var createddModel = await profile.DiskIO.CreateAsync(newEntryPath, IsFolder, pm.CancellationToken); logger.Info(String.Format("{0} = {1} ({2})", DestinationKey, createddModel.FullPath, IsFolder ? "Folder" : "File")); pm.SetValue(DestinationKey, createddModel); return(CoreScriptCommands.NotifyEntryChanged(ChangeType.Created, null, DestinationKey, NextCommand)); }