public void StartComposing(ICollection <IListEntry> entires, EntrySource source) { Reset(); sources.Enqueue(source); currentMergedList = entires.ToList(); entryProcessingStrategy = EntryProcessingFactory.Instance.Get(source); }
public async Task <CharadesEntry> MakeNextCharadesEntry() { bool shouldGoToNextSource = nextEntryIndex == currentMergedList.Count; if (shouldGoToNextSource) { nextEntryIndex = 0; if (sources.Count != 0) { currentSource = sources.Dequeue(); await GetCurrentMergedListFromSource(); } else if (otherSources.Count != 0) { adaptationStrategy = AdaptationIncluding.OnlyKnownInOthers; currentSource = otherSources.Dequeue(); await GetCurrentMergedListFromSource(); } else { return(null); } } var entry = currentMergedList[nextEntryIndex++]; var nextCharades = await CreateNextCharades(entry); return(nextCharades); }
private async Task SyncViewAndModelAsync(EntrySource src, string NewValueAsString) { bool success; string ErrorString; if (src == EntrySource.Height) { success = Model.SetHeightAsString(NewValueAsString, out ErrorString); HeightErrorLabel.IsVisible = !success; } else { success = Model.SetWeightAsString(NewValueAsString, out ErrorString); WeightErrorLabel.IsVisible = !success; } if (Model.BmiValue != null) { BmiLabel.IsVisible = true; OutputLabel.IsVisible = true; OutputLabel.Text = string.Format("{0:f1}", Model.BmiValue); } else { BmiLabel.IsVisible = false; OutputLabel.IsVisible = false; } if (!success) { await GiveFeedbackAsync(ErrorString); } }
public IEntryProvider Get(EntrySource source) { var provider = providers.FirstOrDefault(s => s.GetType().Name.Contains(source.ToString())); return(provider); }
public IEntryProcessingStrategy Get(EntrySource source) { return(strategies.First(s => s.GetType().Name.StartsWith(source.ToString()))); }
private ICollection <IEntryInstance> GetEntriesAdaptations(ICollection <IEntryInstance> entries, EntrySource source) { var adaptations = entries .Where(a => a.Related.Adaptations != null && a.Related.Adaptations.Count != 0) .SelectMany(a => a.Related.Adaptations.Select(ad => ad.MalId)) .Distinct().ToArray(); var provider = providerFactory.Get(source); var adaptationEntries = adaptations.Select(a => provider.Get(a)).Where(a => a != null).ToList(); return(adaptationEntries); }
private ICollection <IEntryInstance> GetAllAdaptations(ICollection <IEntryInstance> animeEntries, EntrySource source) { ICollection <IEntryInstance> entries = new List <IEntryInstance>(); var adaptationsFromEntries = GetEntriesAdaptations(animeEntries, source); var provider = providerFactory.Get(source); foreach (var adaptation in adaptationsFromEntries) { var nextAdaptations = GetFranchiseEntries(adaptation.Id, provider); entries.AddRange(nextAdaptations); } entries = entries.Distinct().ToList(); return(entries); }
public async Task <bool> IsIgnored(long id, EntrySource source) { return(await context.Ignored.AnyAsync(i => i.Id == id && i.Source == source)); }
public async Task <IgnoredEntry> Get(long id, EntrySource source) { return(await context.Ignored.FirstOrDefaultAsync(i => i.Id == id && i.Source == source)); }