public static void RemoveQuestionsAndSave(string websiteUrl, string tag) { List <string> keysToDelete = new List <string>(); foreach (var keyValuePair in questionsCollection) { BindableQuestion tempQuestion = new BindableQuestion( keyValuePair.Key, keyValuePair.Value.GetObject()); // Is it the selected website? // A null websiteUrl matches all questions. if (websiteUrl == null || tempQuestion.WebsiteUrl == websiteUrl) { // Is it the selected tag? // A null tag matches any tag. if (tag == null || tempQuestion.Tags.ContainsKey(tag)) { keysToDelete.Add(keyValuePair.Key); } } } RemoveQuestionsAndSave(keysToDelete); }
// TODO: I fthis is an expensive operation, maybe we should consider to cache the result. public static IList <BindableQuestion> GetSortedQuestions() { CheckSettingsAreLoaded(); List <BindableQuestion> list = new List <BindableQuestion>(); foreach (var keyValuePair in questionsCollection) { BindableQuestion tempQuestion = new BindableQuestion( keyValuePair.Key, keyValuePair.Value.GetObject()); list.Add(tempQuestion); } // Sort the items! list.Sort((a, b) => { // Multiply by -1 to sort in ascending order. return(DateTimeOffset.Compare(a.PubDate, b.PubDate) * -1); }); return(list); }
// TODO: I fthis is an expensive operation, maybe we should consider to cache the result. public static IList<BindableQuestion> GetSortedQuestions() { CheckSettingsAreLoaded(); List<BindableQuestion> list = new List<BindableQuestion>(); foreach (var keyValuePair in questionsCollection) { BindableQuestion tempQuestion = new BindableQuestion( keyValuePair.Key, keyValuePair.Value.GetObject()); list.Add(tempQuestion); } // Sort the items! list.Sort((a, b) => { // Multiply by -1 to sort in ascending order. return DateTimeOffset.Compare(a.PubDate, b.PubDate) * -1; }); return list; }
public static void RemoveQuestionsAndSave(string websiteUrl, string tag) { List<string> keysToDelete = new List<string>(); foreach (var keyValuePair in questionsCollection) { BindableQuestion tempQuestion = new BindableQuestion( keyValuePair.Key, keyValuePair.Value.GetObject()); // Is it the selected website? // A null websiteUrl matches all questions. if (websiteUrl == null || tempQuestion.WebsiteUrl == websiteUrl) { // Is it the selected tag? // A null tag matches any tag. if (tag == null || tempQuestion.Tags.ContainsKey(tag)) { keysToDelete.Add(keyValuePair.Key); } } } RemoveQuestionsAndSave(keysToDelete); }