Exemplo n.º 1
0
 private StableSession()
 {
     if (LoadSettings() == false)
     {
         _settings = new SettingsObject();
     }
     CurrentUserData = null;
 }
Exemplo n.º 2
0
        private bool LoadSettings()
        {
            IFolder rootFolder = FileSystem.Current.LocalStorage;
            if (rootFolder.CheckExistsAsync("Settings").Result != ExistenceCheckResult.FolderExists)
            {
                _settings = null;
                return false;
            }

            IFolder settingsFolder = rootFolder.GetFolderAsync("Settings").Result;
            if (settingsFolder.CheckExistsAsync("starstable").Result != ExistenceCheckResult.FileExists)
            {
                _settings = null;
                return false;
            }
            IFile settingsFile = settingsFolder.GetFileAsync("starstable").Result;
            
            string settingsText = Task.Run(async () => await settingsFile.ReadAllTextAsync()).Result;
            _settings = JsonConvert.DeserializeObject<SettingsObject>(settingsText);
            if (_settings == null)
                return false;

            return true;
        }