示例#1
0
        // build a song to represent a group
        // the GetChildDataItems method returns all songs that belong
        // to this node, and the LINQ statement below calculates the total
        // size, length, and average rating for the album/artist.
        Song BuildGroupDataItem(GroupRow gr)
        {
            var gs = gr.GetDataItems().OfType <Song>();

            return(new Song()
            {
                Name = gr.Group.Name.ToString(),
                Size = (long)gs.Sum(s => s.Size),
                Duration = (long)gs.Sum(s => s.Duration),
                Rating = (int)(gs.Average(s => s.Rating) + 0.5)
            });
        }