示例#1
0
        private static void UpdateLanguageAndCountryCounts(
            Dictionary <string, Tuple <uint, uint> > languageCounts,
            Dictionary <string, Tuple <uint, uint> > countryCounts,
            BookRead book)
        {
            if (!languageCounts.ContainsKey(book.OriginalLanguage))
            {
                languageCounts.Add(book.OriginalLanguage, new Tuple <uint, uint>(1, book.Pages));
            }
            else
            {
                var updatedCounts =
                    new Tuple <uint, uint>(
                        languageCounts[book.OriginalLanguage].Item1 + 1,
                        languageCounts[book.OriginalLanguage].Item2 + book.Pages);
                languageCounts[book.OriginalLanguage] = updatedCounts;
            }

            if (!countryCounts.ContainsKey(book.Nationality))
            {
                countryCounts.Add(book.Nationality, new Tuple <uint, uint>(1, book.Pages));
            }
            else
            {
                var updatedCounts =
                    new Tuple <uint, uint>(
                        countryCounts[book.Nationality].Item1 + 1,
                        countryCounts[book.Nationality].Item2 + book.Pages);
                countryCounts[book.Nationality] = updatedCounts;
            }
        }
示例#2
0
 public TalliedBook(BookRead book)
 {
     Book = book;
 }