private void Save() { ApplicationDataContainer root = ApplicationData.Current.LocalSettings; root.DeleteContainer("Remote"); ApplicationDataContainer remote = root .CreateContainer("Remote", ApplicationDataCreateDisposition.Always); foreach (RemoteClient client in remoteClients.Values) { ApplicationDataContainer item = remote .CreateContainer(client.Key.ToString(), ApplicationDataCreateDisposition.Always); item.Values["Name"] = client.Name; item.Values["Url"] = client.Url; item.Values["AuthenticationToken"] = client.AuthenticationToken; } root.DeleteContainer("Local"); if (localClient != null) { ApplicationDataContainer localContainer = root.CreateContainer("Local", ApplicationDataCreateDisposition.Always); localContainer.Values["Key"] = localClient.Key; localContainer.Values["Port"] = localClient.Port; localContainer.Values["AuthenticationToken"] = localClient.AuthenticationToken; localContainer.Values["Interval"] = localClient.Interval; localContainer.Values["Delay"] = localClient.Delay; } }
/// <summary> /// Удаляет вложеный контейнер из текущего /// </summary> /// <param name="name">Имя удаляемого контейнера</param> protected void DeleteContainer(string name) { _container.DeleteContainer(name); if (_containers.ContainsKey(name)) { _containers.Remove(name); } }
private async void btnDeleteSettings_Click(object sender, RoutedEventArgs e) { var loader = new Windows.ApplicationModel.Resources.ResourceLoader(); MessageDialog dialog = new MessageDialog(loader.GetString("DeleteInfoConfirmText"), loader.GetString("DeleteInfoConfirmTitle")); var yes = new UICommand(loader.GetString("DeleteInfoConfirmYes")); yes.Id = 0; var no = new UICommand(loader.GetString("DeleteInfoConfirmNo")); no.Id = 1; dialog.Commands.Add(yes); dialog.Commands.Add(no); dialog.DefaultCommandIndex = 1; dialog.CancelCommandIndex = 1; IUICommand command = await dialog.ShowAsync(); if ((int)command.Id == 0) { ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; if (localSettings.Containers.ContainsKey("MiBand")) { localSettings.DeleteContainer("MiBand"); MessageDialog dialog2 = new MessageDialog(loader.GetString("DeleteInfoSuccessText"), loader.GetString("DeleteInfoSuccessTitle")); await dialog2.ShowAsync(); Application.Current.Exit(); } } }
public void Delete(string containerName) { if (localSettings.Containers.ContainsKey(containerName)) { localSettings.DeleteContainer(containerName); } }
private async void btnClearStorage_Click(object sender, RoutedEventArgs e) { await ExecuteActionAsync(sender, async() => { using (var readModels = readModelContextFactory.Create()) { readModels.Database.EnsureDeleted(); readModels.Database.EnsureCreated(); } using (var eventSourcing = eventSourcingContextFactory.Create()) { eventSourcing.Database.EnsureDeleted(); eventSourcing.Database.EnsureCreated(); await eventSourcing.Database.MigrateAsync(); } ApplicationDataContainer rootContainer = storageContainerFactory.Create(); foreach (string containerName in rootContainer.Containers.Select(c => c.Key)) { rootContainer.DeleteContainer(containerName); } await ShowExitDialogAsync(); }); }
private void DeleteAllPlayerData() { ApplicationDataContainer database = ApplicationData.Current.LocalSettings; // ※補足 database.DeleteContainer("key") -> データベースにあるデータを全部消す database.DeleteContainer("key"); }
public static void Delete(string messageId) { if (!RelayMessageContainer.Containers.ContainsKey(messageId)) { return; } RelayMessageContainer.DeleteContainer(messageId); }
public async Task DeletContainer() { if (Exist) { await Task.Run(() => localSettings.DeleteContainer(Manager)); Exist = false; } }
/// <summary> /// 删除容器 /// </summary> /// <param name="con">根容器</param> /// <param name="name">想删除容器的名字</param> public void DeleteContainer(ApplicationDataContainer con, string name) { try { con.DeleteContainer(name); } catch (Exception ex) { Debug.Write(ex.Message); } }
public virtual void DeleteContainer(string containerKey) { if (ApplicationDataContainer.Containers.ContainsKey(containerKey)) { ApplicationDataContainer.DeleteContainer(containerKey); } else { throw new KeyNotFoundException(); } }
public void RemoveAllSettings() { foreach (System.Collections.Generic.KeyValuePair <string, ApplicationDataContainer> item in LocalSettings.Containers.ToArray()) { LocalSettings.DeleteContainer(item.Key); } foreach (System.Collections.Generic.KeyValuePair <string, ApplicationDataContainer> item in RoamingSettings.Containers.ToArray()) { RoamingSettings.DeleteContainer(item.Key); } }
public void Clear(bool deep, IPropertySet values, ApplicationDataContainer container) { values.Clear(); if (deep) { foreach (var item in container.Containers.ToArray()) { container.DeleteContainer(item.Key); } } }
/// <summary> /// /// </summary> /// <param name="container"></param> public static void RemoveContainer(string container) { if (localSettings.Containers.ContainsKey(container)) { localSettings.DeleteContainer(container); } else { throw new KeyNotFoundException(); } }
public void Remove(string key, IPropertySet values, ApplicationDataContainer container) { if (values.ContainsKey(key)) { values.Remove(key); } if (container.Containers.ContainsKey(key)) { container.DeleteContainer(key); } }
//删除某种设置 //不考虑嵌套Container public void RemoveSetting(string settingName, bool isContainer = false) { if (isContainer) { dataSettings.DeleteContainer(settingName); } else { dataSettings.Values.Remove(settingName); } }
private async void bttnDelete_Tapped(object sender, TappedRoutedEventArgs e) { MessageDialog msg = new MessageDialog("Are you sure to delete this note?", "Delete Confirmation"); UICommand noCommand = new UICommand(); noCommand.Label = "No"; noCommand.Id = 1; msg.Commands.Add(noCommand); UICommand yesCommand = new UICommand(); yesCommand.Label = "Yes"; yesCommand.Id = 2; msg.Commands.Add(yesCommand); IUICommand selectedCommand = await msg.ShowAsync(); if (selectedCommand != null) { if ((int)selectedCommand.Id == 2) { ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; ApplicationDataCompositeValue composite; int lastIndex = Convert.ToInt32(localSettings.Values["NoteNum"].ToString()); for (int i = 0; i < lastIndex; i++) { try { if (localSettings.Values[i.ToString()] != null) { composite = localSettings.Values[i.ToString()] as ApplicationDataCompositeValue; if (selectedNote.Title == composite["Title"] as string && selectedNote.Content == composite["Content"] as string) { int j = i; while ((j + 1) < lastIndex) { localSettings.Values[j.ToString()] = localSettings.Values[(j + 1).ToString()]; j++; } composite = localSettings.Values[(lastIndex - 1).ToString()] as ApplicationDataCompositeValue; localSettings.DeleteContainer("composite"); localSettings.Values["NoteNum"] = Convert.ToInt32(localSettings.Values["NoteNum"].ToString()) - 1; break; } } } catch { } } Frame.Navigate(typeof(MainPage)); } } }
/// <summary> /// Will delete any stored Metadata class information from application setting. /// </summary> public void WipeUserInfoSettings() { try { IEnumerator <KeyValuePair <string, ApplicationDataContainer> > containerList = currentLocalSettings.Containers.GetEnumerator(); while (containerList.MoveNext()) { currentLocalSettings.DeleteContainer(containerList.Current.Key); } } catch (Exception) { } }
private async void createbutton_Click(object sender, RoutedEventArgs e) { var dialog = new MessageDialog(""); if (!localSettings.Containers.ContainsKey(newaccount.Text)) { if (newpassword.Password == checkpassword.Password && newpassword.Password != null) { /*example: localSettings.Containers["accountContainer"].Values["exampleSetting"] = "Hello Windows";*/ /*此处为方便处理,违规地将应用程序数据容器API ApplicationDataContainer 作为存储用户账号密码以及头像地址的存储容器使用*/ Windows.Storage.ApplicationDataContainer container = localSettings.CreateContainer(newaccount.Text, Windows.Storage.ApplicationDataCreateDisposition.Always); //创建新账号容器 if (localSettings.Containers.ContainsKey(newaccount.Text)) { localSettings.Containers[newaccount.Text].Values["password"] = newpassword.Password; localSettings.Containers[newaccount.Text].Values["avatar"] = "null"; if (await Management.NewAccount(newaccount.Text) == 1) { dialog.Content = "注册成功"; await dialog.ShowAsync(); } else { localSettings.DeleteContainer(newaccount.Text); dialog.Content = "在创建本地文件时出现错误,未能成功创建账号"; await dialog.ShowAsync(); } } else { throw new Exception(String.Format("Key {0} was not found", newaccount.Text)); } } else { dialog.Content = "两次密码输入不一致"; await dialog.ShowAsync(); } } else { dialog.Content = "账号已存在"; await dialog.ShowAsync(); } }
public bool DeleteTask(SmartTask task) // Deletes a task from app memory then removes it from the SmartSchedule data structure { bool status = true; // Return value for whether or not it succeeded string taskID = task.StorageID(); string scheduleID = this.StorageID(); Debug.WriteLine($"(UNFINISHED) Deleting task: {taskID} from schedule {scheduleID}"); // Retrieve the data from application memory (note: open existing) scheduleData = startupSettings.CreateContainer(scheduleID, ApplicationDataCreateDisposition.Existing); // Remove task key from storage keys if (storageKeys.Contains(taskID)) { storageKeys.Remove(taskID); } else { Debug.WriteLine($"Unexpected error: {taskID} not found in storage keys!"); status = false; } scheduleData.Values.Remove("storageKeys"); scheduleData.Values["storageKeys"] = storageKeysString; // Remove task from app storage try { tasksContainer.DeleteContainer(taskID); } catch (Exception e) { Debug.WriteLine($"Error in task delete from SmartSchedule: Task container {taskID} was not found.\nException message: {e.Message}"); } // Remove task from SmartSchedule - return value represents whether or not the remove was successful status = removeTaskFromSchedule(task) && status; // Update the UI to reflect a new task added to the schedule //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(main_LV_schedule.ItemsSource))); return(status); }
public async Task <bool> CreateSettings() { ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; // si ya existe se borra if (localSettings.Containers.ContainsKey("MiBand")) { localSettings.DeleteContainer("MiBand"); } // se crea nuevo var settings = localSettings.CreateContainer("MiBand", ApplicationDataCreateDisposition.Always); // si por lo que sea no se crea salimos if (!localSettings.Containers.ContainsKey("MiBand")) { return(false); } Settings = settings; // creamos todas las claves settings.Values["Name"] = "MI"; settings.Values["MAC"] = await getAddress(); settings.Values["BatteryInfo"] = (new BatteryInfo(new byte[] {})).ToSetting(); settings.Values["DailyGoal"] = 8000; settings.Values["CurrentSteps"] = 0; settings.Values["Alarm1"] = (new Alarm(0, false, DateTime.Today, Alarm.Everyday, false)).ToSetting(); settings.Values["Alarm2"] = (new Alarm(1, false, DateTime.Today, Alarm.Everyday, false)).ToSetting(); settings.Values["Alarm3"] = (new Alarm(2, false, DateTime.Today, Alarm.Everyday, false)).ToSetting(); settings.Values["ColorTheme"] = ColorTheme.Aqua.ToInt32(); settings.Values["WearLocation"] = (int)WearLocation.LeftHand; settings.Values["DeviceInfo"] = (new DeviceInfo(new byte[] {})).ToSetting(); settings.Values["UserInfo"] = (new UserInfo(true, 18, 180, 65, 0x01, "usuario 1")).ToSetting(); return(true); }
void DeleteContainer_Click(Object sender, RoutedEventArgs e) { localSettings.DeleteContainer(containerName); DisplayOutput(); }
public static void DeleteContainer() { _localSettings.DeleteContainer(_containerName); }
public void Delete() { _containerParent.DeleteContainer(_containerName); }
public void Clear() { settings.DeleteContainer("TWStore"); }
public async void LoadAsync(PlexViewModel viewModel) { version = settings.Values[KEY_VERSION] as int? ?? 1; this.viewModel = viewModel; foreach (string showKey in settings.Containers.Keys) { ApplicationDataContainer showContainer = settings.Containers[showKey]; Debug.WriteLine($"Show: {showContainer.Values["name"] as string}|{showContainer.Values["showPath"] as string}"); Show show = new Show(showKey, showContainer.Values["name"] as string, showContainer.Values["showPath"] as string); StorageFolder showFolder; try { showFolder = await StorageFolder.GetFolderFromPathAsync(show.ShowPath); } catch (FileNotFoundException) { settings.DeleteContainer(showKey); continue; } catch (UnauthorizedAccessException) { settings.DeleteContainer(showKey); continue; } viewModel.Shows.Add(show); SortedList <int, Season> seasons = new SortedList <int, Season>(); Dictionary <string, HashSet <string> > filenames = new Dictionary <string, HashSet <string> >(); foreach (string seasonKey in showContainer.Containers.Keys) { ApplicationDataContainer seasonContainer = showContainer.Containers[seasonKey]; Debug.WriteLine($"Season: {seasonContainer.Values["number"] as int? ?? -1}|{seasonKey}"); Season season = new Season(seasonContainer.Values["number"] as int? ?? -1, seasonKey) { Show = show }; StorageFolder seasonFolder; try { seasonFolder = await showFolder.GetFolderAsync(season.GetFolderName()); } catch (FileNotFoundException) { showContainer.DeleteContainer(seasonKey); continue; } filenames.Add(seasonFolder.Name, new HashSet <string>()); SortedList <int, Episode> episodes = new SortedList <int, Episode>(); foreach (string episodeKey in seasonContainer.Containers.Keys) { ApplicationDataContainer episodeContainer = seasonContainer.Containers[episodeKey]; Debug.WriteLine($"Episode: {episodeContainer.Values["number"] as int? ?? -1}|{episodeContainer.Values["episodePath"] as string}|{episodeContainer.Values["originalFilename"] as string}"); Episode episode = new Episode(episodeContainer.Values["number"] as int? ?? -1, episodeContainer.Values["episodePath"] as string, episodeContainer.Values["originalFilename"] as string) { ManuallySet = episodeContainer.Values["manuallySet"] as bool? ?? false }; StorageFile file; try { file = await seasonFolder.GetFileAsync(episode.Filename); } catch (FileNotFoundException) { seasonContainer.DeleteContainer(episodeKey); continue; } filenames[season.Name].Add(episode.Filename); if (!episodes.ContainsKey(episode.Number)) { episodes.Add(episode.Number, episode); } } foreach (Episode episode in episodes.Values) { season.AddEpisode(episode); } seasons.Add(season.Number, season); } foreach (Season season in seasons.Values) { show.AddSeason(season); } // check for unsorted eps QueryOptions queryOptions = new QueryOptions(CommonFileQuery.OrderByName, MainPage.VideoExtensions) { FolderDepth = FolderDepth.Shallow }; StorageFileQueryResult queryResult = showFolder.CreateFileQueryWithOptions(queryOptions); IReadOnlyList <StorageFile> unsortedEpisodeFiles = await queryResult.GetFilesAsync(); foreach (StorageFile episodeFile in unsortedEpisodeFiles) { if (IsEpisodeNamedCorrectly(episodeFile.Name, show.Name)) { string correctFolderName = GetCorrectFolderName(episodeFile.Name); Episode episode = new Episode(GetEpisodeNumber(episodeFile.Name), episodeFile.Path, episodeFile.Name); StorageFolder correctSeasonFolder; try { correctSeasonFolder = await showFolder.GetFolderAsync(correctFolderName); } catch (FileNotFoundException) { correctSeasonFolder = await showFolder.CreateFolderAsync(correctFolderName); } // move to correct folder await episodeFile.MoveAsync(correctSeasonFolder); // restore to season int seasonNumber = GetSeasonNumber(episode.Filename); if (!seasons.ContainsKey(seasonNumber)) { Season newSeason = new Season(seasonNumber, correctFolderName); seasons.Add(seasonNumber, newSeason); show.InsertSeason(newSeason); showContainer.CreateContainer(correctSeasonFolder.Name, ApplicationDataCreateDisposition.Always); } Season season = seasons[seasonNumber]; int i; for (i = 0; i < season.NumberEpisodes; i++) { if (episode.Number < season.Episodes[i].Number) { break; } } season.InsertEpisode(i, episode); // save ep data ApplicationDataContainer episodeContainer = showContainer.Containers[correctSeasonFolder.Name].CreateContainer(episode.Filename, ApplicationDataCreateDisposition.Always); episodeContainer.Values["number"] = episode.Number; episodeContainer.Values["manuallySet"] = episode.ManuallySet; episodeContainer.Values["episodePath"] = episode.EpisodePath; episodeContainer.Values["originalFilename"] = episode.OriginalFilename; } else { Debug.WriteLine($"UnsortedEpisode: -1 {episodeFile.Path}"); Episode episode = new Episode(-1, episodeFile.Path); show.UnsortedSeason.AddEpisode(episode); } } IReadOnlyList <StorageFolder> folders = await showFolder.GetFoldersAsync(); foreach (StorageFolder seasonFolder in folders) { if (!filenames.ContainsKey(seasonFolder.Name)) { filenames.Add(seasonFolder.Name, new HashSet <string>()); } queryResult = seasonFolder.CreateFileQueryWithOptions(queryOptions); IReadOnlyList <StorageFile> episodeFiles = await queryResult.GetFilesAsync(); foreach (StorageFile episodeFile in episodeFiles) { if (!filenames[seasonFolder.Name].Contains(episodeFile.Name)) { if (IsEpisodeNamedCorrectly(episodeFile.Name, show.Name)) { string correctFolderName = GetCorrectFolderName(episodeFile.Name); Episode episode = new Episode(GetEpisodeNumber(episodeFile.Name), episodeFile.Path, episodeFile.Name); StorageFolder correctSeasonFolder; if (correctFolderName != seasonFolder.Name) { try { correctSeasonFolder = await showFolder.GetFolderAsync(correctFolderName); } catch (FileNotFoundException) { correctSeasonFolder = await showFolder.CreateFolderAsync(correctFolderName); } // move to correct folder await episodeFile.MoveAsync(correctSeasonFolder); } else { correctSeasonFolder = seasonFolder; } // restore to season int seasonNumber = GetSeasonNumber(episode.Filename); if (!seasons.ContainsKey(seasonNumber)) { Season newSeason = new Season(seasonNumber, correctFolderName); seasons.Add(seasonNumber, newSeason); show.InsertSeason(newSeason); showContainer.CreateContainer(correctSeasonFolder.Name, ApplicationDataCreateDisposition.Always); } Season season = seasons[seasonNumber]; int i; for (i = 0; i < season.NumberEpisodes; i++) { if (episode.Number < season.Episodes[i].Number) { break; } } season.InsertEpisode(i, episode); // save ep data ApplicationDataContainer episodeContainer = showContainer.Containers[correctSeasonFolder.Name].CreateContainer(Path.GetFileNameWithoutExtension(episode.Filename), ApplicationDataCreateDisposition.Always); episodeContainer.Values["number"] = episode.Number; episodeContainer.Values["manuallySet"] = episode.ManuallySet; episodeContainer.Values["episodePath"] = episode.EpisodePath; episodeContainer.Values["originalFilename"] = episode.OriginalFilename; } else { Debug.WriteLine($"UnsortedEpisode: -1 {episodeFile.Path}"); Episode episode = new Episode(-1, episodeFile.Path); show.UnsortedSeason.AddEpisode(episode); } } } } } Debug.WriteLine("done loading"); }
/// <summary> /// 删除设置容器 /// </summary> /// <param name="key"></param> public static void RemoveContainer(string containerName) { localSettings.DeleteContainer(containerName); }
private void DelKuaiDiData(object sender, RoutedEventArgs e) { localData.DeleteContainer("KuaiDiData"); Load_data(); }
public void DeleteContainer(string name) { _container.DeleteContainer(name); }