private async Task getSettingsAsync() { if (_settings != null) { return; } var jsonSerializer = new DataContractJsonSerializer(typeof(Settings)); try { using (var stream = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync(Constants.SettingsFile)) { _settings = (Settings)jsonSerializer.ReadObject(stream); } } catch { _settings = new Settings(); } }
public async Task saveSettingsAsync(Settings settings) { _settings = settings; var jsonSerializer = new DataContractJsonSerializer(typeof(Settings)); using (var stream = await ApplicationData.Current.LocalFolder.OpenStreamForWriteAsync(Constants.SettingsFile, CreationCollisionOption.ReplaceExisting)) { jsonSerializer.WriteObject(stream, _settings); } }