예제 #1
0
        public async Task <CategoryRecord> GetItemsByCategoryAsync()
        {
            CategoryRecord result = new CategoryRecord();

            foreach (IHistoryProvider provider in Providers)
            {
                HistoryRecord record = await provider.GetAsync();

                List <HistoryItem> items = record.Items;
                items.Sort(new HistoryItemComparer());

                foreach (HistoryItem historyItem in items)
                {
                    try
                    {
                        IList <HistoryItem> list = result[historyItem.Category];
                        list.Add(historyItem);
                    }
                    catch (KeyNotFoundException)
                    {
                        // If we don't have a list for this key, then create one and add the item to it
                        IList <HistoryItem> list = new List <HistoryItem>();
                        list.Add(historyItem);

                        result[historyItem.Category] = list;
                    }
                }
            }

            return(result);
        }
예제 #2
0
        public async Task <HistoryRecord> GetCombinedRecordsAsync()
        {
            HistoryRecord record = new HistoryRecord("Combined");

            foreach (IHistoryProvider provider in Providers)
            {
                record.Items.AddRange((await provider.GetAsync()).Items);
            }

            return(record);
        }
예제 #3
0
        public HistoryRecord GetCombinedRecords()
        {
            HistoryRecord record = new HistoryRecord("Combined");

            foreach (IHistoryProvider provider in Providers)
            {
                record.Items.AddRange(provider.Get().Items);
            }

            return(record);
        }