public static string AsDisplay(this BrewKind self) { switch (self) { case BrewKind.None: return("All"); case BrewKind.PSV: return("PS Vita"); default: return(self.ToString()); } }
public bool IsKindRetrievable(BrewKind kind) { switch (kind) { case BrewKind.PSV: return(SHMRegistryHelper.Instance.UseVitaDB || !string.IsNullOrEmpty(SHMRegistryHelper.Instance.PSV)); case BrewKind.PS3: return(!string.IsNullOrEmpty(SHMRegistryHelper.Instance.PS3)); case BrewKind.PS4: return(!string.IsNullOrEmpty(SHMRegistryHelper.Instance.PS4)); case BrewKind.All: return(kind.GetFlags().Where(x => x != BrewKind.All && x != BrewKind.None).Any(x => IsKindRetrievable(x))); default: return(false); } }
public async Task <IEnumerable <Brew> > RetrieveAsync(BrewKind kind) { List <Brew> brews = new List <Brew>(); foreach (var k in kind.GetFlags()) { string uri = string.Empty; switch (k) { case BrewKind.PSV: uri = SHMRegistryHelper.Instance.UseVitaDB ? null : SHMRegistryHelper.Instance.PSV; break; case BrewKind.PS3: uri = SHMRegistryHelper.Instance.PS3; break; case BrewKind.PS4: uri = SHMRegistryHelper.Instance.PS4; break; default: continue; } brews.AddRange((k == BrewKind.PSV && SHMRegistryHelper.Instance.UseVitaDB ? Mapper.Map <IEnumerable <Brew> >(await RetrieveRawFromVitaDbAsync()) : Mapper.Map <IEnumerable <Brew> >(await RetrieveRawAsync(uri))).Select(x => x.With(y => y.Kind = k))); } return(brews); }
public async Task <IEnumerable <Downloadable <Brew> > > RetrieveDownloadableAsync(BrewKind kind) => (await RetrieveAsync(kind)).Select(x => x.ToDownloadable(BrewDownloader.Instance.IsDownloaded(x) ? DownloadState.Downloaded : DownloadState.WaitingToDownload));