示例#1
0
        /// <summary>
        /// Issued only the SRS levels are sure to be loaded.
        /// Updates the ItemsPerLevel property according to the
        /// current review info.
        /// </summary>
        private void UpdateItemsPerLevel()
        {
            lock (_updateLock)
            {
                List<SrsItemPerLevelGroup> groups = new List<SrsItemPerLevelGroup>();
                foreach (SrsLevelGroup levelGroup in SrsLevelStore.Instance.CurrentSet)
                {
                    // For each loaded level group...
                    // Create the matching item per level group object.
                    SrsItemPerLevelGroup itemPerLevelGroup = new SrsItemPerLevelGroup();
                    itemPerLevelGroup.Group = levelGroup;

                    List<SrsItemPerLevel> itemPerLevelList = new List<SrsItemPerLevel>();
                    foreach (SrsLevel level in levelGroup.Levels)
                    {
                        // Browse the levels in the group. For each level...
                        // Create the matching item per level object.
                        SrsItemPerLevel itemPerLevel = new SrsItemPerLevel();
                        itemPerLevel.Level = level;
                        var matches = CurrentReviewInfo.ReviewsPerLevel
                            .Where(kvp => kvp.Key == level.Value);

                        if (matches.Any())
                        {
                            // If there is a match with the retrieved reviews per level
                            // values, use the item count.
                            itemPerLevel.ItemCount = matches.First().Value;
                        }

                        // In any case (even when there is no match), add the "item per level"
                        // object to the list.
                        itemPerLevelList.Add(itemPerLevel);
                    }

                    // Set the list as the set of levels of the "items per level group" item.
                    itemPerLevelGroup.Levels = itemPerLevelList.ToArray();

                    // Add the "items per level group" to the list.
                    groups.Add(itemPerLevelGroup);
                }

                // Set the property value as the list of "items per level group".
                ItemsPerLevelGroup = groups.ToArray();
            }
        }
 public SrsItemPerLevelGroup()
 {
     Levels = new SrsItemPerLevel[] {};
 }
 public SrsItemPerLevelGroup()
 {
     Levels = new SrsItemPerLevel[]{};
 }