Ejemplo n.º 1
0
        public void LoadProfiles(IProgressReceiver progressReceiver)
        {
            IPlayerProfileService profileService = ServiceProvider.GetRequiredService <IPlayerProfileService>();
            IStorageSystem        storage        = ServiceProvider.GetRequiredService <IStorageSystem>();

            progressReceiver.UpdateProgress(0, StatusMessage);
            if (storage.TryReadJson(ProfilesFile, out ProfilesFileFormat saveFile))
            //if (File.Exists(ProfilesFile))
            {
                progressReceiver.UpdateProgress(50, StatusMessage);

                //	ProfilesFileFormat saveFile = null;
                SavedProfile[] profiles = null;


                progressReceiver.UpdateProgress(50, StatusMessage);

                if (saveFile != null)
                {
                    profiles = saveFile.Profiles;

                    if (!string.IsNullOrWhiteSpace(saveFile.SelectedProfile))
                    {
                        progressReceiver.UpdateProgress(75, StatusMessage);

                        foreach (var profile in profiles)
                        {
                            //profile.Profile.Type = profile.Type;// == ProfileType.Bedrock;
                            if (profile.Profile.Uuid.Equals(saveFile.SelectedProfile))
                            {
                                progressReceiver.UpdateProgress(90, StatusMessage);
                                LastUsedProfile = profile;
                                //profileService.TryAuthenticateAsync(profile.Profile);
                                //profileService.CurrentProfile = profile;
                                break;
                            }
                        }
                    }

                    progressReceiver.UpdateProgress(99, StatusMessage);
                    foreach (var profile in profiles)
                    {
                        Profiles.Add(profile.Profile.Uuid, profile);
                    }
                }
                else
                {
                    Log.Warn($"Profiles file not found.");
                }
            }
            else
            {
                storage.TryWriteJson(ProfilesFile, new ProfilesFileFormat());
                //	File.WriteAllText(ProfilesFile, JsonConvert.SerializeObject(new ProfilesFileFormat(), Formatting.Indented));
            }

            progressReceiver.UpdateProgress(100, StatusMessage);
        }
Ejemplo n.º 2
0
 public void Load()
 {
     if (!_storage.TryReadJson <AlexOptions>(StorageKey, out var options))
     {
         // no options file?
         options = new AlexOptions();
         if (!_storage.TryWriteJson <AlexOptions>(StorageKey, options))
         {
             // uhmmm...
             throw new IOException("Unable to write default AlexOptions!");
         }
     }
 }
Ejemplo n.º 3
0
        public void Load()
        {
            if (_optionsLoaded)
            {
                return;
            }

            if (_storage.TryReadJson(StorageKey, out AlexOptions options))
            {
                AlexOptions = options;
            }
            else
            {
                Log.Warn($"Could not read from storage.");
            }

            _optionsLoaded = true;
        }
Ejemplo n.º 4
0
 public void Load()
 {
     if (_storage.TryReadJson(StorageKey, out SavedServerEntry[] newEntries))