public async Task GetRaces() { IsRefreshing = true; Races.Clear(); string url = "http://itweb.fvtc.edu/wetzel/marathon/races/"; string json; using (System.Net.WebClient webClient = new System.Net.WebClient()) { json = await webClient.DownloadStringTaskAsync(url); } GetRacesApiResult result = Newtonsoft.Json.JsonConvert.DeserializeObject <GetRacesApiResult>(json); foreach (Race race in result.races) { RaceViewModel vm = new RaceViewModel(this.Navigation) { Race = race }; this.Races.Add(vm); } IsRefreshing = false; }
public void Unload() { Log.Info(Log.LogSource.PoxDB, "Database.Unload() called"); if (!ready) { return; } // todo: what if it is loading? Champions.Clear(); Abilities.Clear(); Abilities_similar.Clear(); Spells.Clear(); Relics.Clear(); Equipments.Clear(); Factions.Clear(); Races.Clear(); Classes.Clear(); Rarities.Clear(); Expansions.Clear(); AbilityNames.Clear(); ready = false; }
public override void Close() { ChangeTracker.IsForecastOpen = false; Mediator.UnregisterRecipientAndIgnoreTags(this); Races.Clear(); LineSr.UnsubscribeFromEnent(DataCopy_DataSqlUpdateSucceeded); base.Close(); }
/// <summary> /// Clears all <c>Lists</c> and <c>Dictionaries</c>. /// </summary> void ClearData() { Spells.Clear(); SpellsChanged.Clear(); Races.Clear(); RacesChanged.Clear(); Classes.Clear(); ClassesChanged.Clear(); }
private async void OnRefresh() { IsBusy = true; await Task.Yield(); // Clear the list or you'll get duplicates upon resuming Races.Clear(); // get the list of races IEnumerable <Race> races = await _dataService.GetRacesAsync(); var previous = new Group <Race>() { Name = "Previous Races" }; var current = new Group <Race>() { Name = "Current Races" }; var future = new Group <Race>() { Name = "Upcoming Races" }; var now = DateTimeOffset.Now; foreach (var race in races) { if (race.StartDate > now) { future.Add(race); } else if (race.EndDate < now) { previous.Add(race); } else { current.Add(race); } } // sort items current.Sort(i => i.StartDate ?? DateTimeOffset.MinValue); future.Sort(i => i.StartDate ?? DateTimeOffset.MinValue); previous.SortDescending(i => i.EndDate ?? DateTimeOffset.MaxValue); Races .AddGroupIfNotEmpty(current) .AddGroupIfNotEmpty(future) .AddGroupIfNotEmpty(previous); IsBusy = false; }
/// <summary> /// Forces garbage collection. /// </summary> public void Clear() { GameObjects.Clear(); TranslationLookup.Clear(); Translations.Clear(); Races.Clear(); StatStructures.Clear(); TextureAtlases.Clear(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }
private void CmdConvertOldConfigFile(Player player, string cmd) { if (!player.HasPermission("RaceSystem.Modify")) { player.SendError(GetMessage("NoPermission", player)); return; } Races.Clear(); var races = GetConfig("Races", "Names", new List <object> { "Dwarf", "Elf", "Human", "Orc" }).OfType <string>().ToList(); foreach (var race in races) { var color = GetConfig("Colors", race, "[9f0000]"); color = color.Replace("[", ""); color = color.Replace("]", ""); Races.Add(new Race(race, color)); } try { var oldData = Interface.Oxide.DataFileSystem.ReadObject <Dictionary <ulong, OldPlayerData> >("RaceSystem"); if (oldData != null) { foreach (var data in oldData) { if (data.Value.Race.IsNullOrEmpty()) { continue; } var race = Races.FirstOrDefault(r => string.Equals(r.Name, data.Value.Race, StringComparison.CurrentCultureIgnoreCase)); if (race != null) { Data.Add(data.Key, new PlayerData(data.Value.CanChange, race)); } } } } catch { Puts("Could not load old data file."); } player.SendMessage(GetMessage("DefaultRestored", player), ChangeTime); SaveRaceData(); }
private void RestoreDefaultRaces(Player player) { if (!player.HasPermission("RaceSystem.Modify")) { player.SendError(GetMessage("NoPermission", player)); return; } Races.Clear(); Data.Clear(); Server.Permissions.Load(); Races.UnionWith(DefaultRaces); player.SendMessage(GetMessage("DefaultRestored", player), ChangeTime); SaveRaceData(); }
protected async override void ViewIsAppearing(object sender, EventArgs e) { base.ViewIsAppearing(sender, e); _userDialogs.ShowLoading("Retrieving All Races"); var user = await _userManager.GetUser(); if (_userManager.IsAnonymous(user)) { Races.Clear(); } else if (Races.Count == 0) { var races = await _dataService.GetRaces(user); var orderedRaces = races.OrderBy(x => x.RaceDate); foreach (var race in orderedRaces) { Races.Add(race); } } SelectedRace = null; _userDialogs.HideLoading(); }