Пример #1
0
        public async Task<string> GetStoredStravaAccessToken()
        {
            if (_settings != null)
                return _settings.StravaAccessToken;

            bool settingsExists = await this.SettingsServiceExists();
            if (settingsExists)
            {
                string settingsAsString = await ServiceLocator.Current.GetInstance<IStorageService>().Local.ReadAllTextAsync(Constants.SETTINGSSTORE);
                _settings = JsonConvert.DeserializeObject<Settings>(settingsAsString);
                return _settings.StravaAccessToken;
            }

            return null;
        }
Пример #2
0
        public async Task<DistanceUnitType> GetStoredDistanceUnitType()
        {
            if (_settings != null)
                return _settings.DistanceUnitType;

            bool settingsExists = await this.SettingsServiceExists();
            if (settingsExists)
            {
                string settingsAsString = await ServiceLocator.Current.GetInstance<IStorageService>().Local.ReadAllTextAsync(Constants.SETTINGSSTORE);
                _settings = JsonConvert.DeserializeObject<Settings>(settingsAsString);
                return _settings.DistanceUnitType;
            }

            return DistanceUnitType.Kilometres;
        }
Пример #3
0
        public async Task SetStravaAccessTokenAsync(string stravaAccessToken)
        {
            if (_settings == null)
            {
                bool settingsExists = await this.SettingsServiceExists();
                if (settingsExists)
                {
                    string settingsAsString = await ServiceLocator.Current.GetInstance<IStorageService>().Local.ReadAllTextAsync(Constants.SETTINGSSTORE);
                    _settings = JsonConvert.DeserializeObject<Settings>(settingsAsString);
                }
                else
                    _settings = new Settings();
            }

            _settings.StravaAccessToken = stravaAccessToken;

            await ServiceLocator.Current.GetInstance<IStorageService>().Local.WriteAllTextAsync(Constants.SETTINGSSTORE, JsonConvert.SerializeObject(_settings));
        }