main
cs 40 lines 1.41 KB
Raw
1 // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 namespace WixToolset.Data.WindowsInstaller.Rows
4 {
5 using System;
6 using System.Collections.ObjectModel;
7
8 /// <summary>
9 /// Indexed container class for summary information rows.
10 /// </summary>
11 public sealed class SummaryInfoRowCollection : KeyedCollection<int, Row>
12 {
13 /// <summary>
14 /// Creates the keyed collection from existing rows in a table.
15 /// </summary>
16 /// <param name="table">The summary information table to index.</param>
17 public SummaryInfoRowCollection(Table table)
18 {
19 if (0 != String.CompareOrdinal("_SummaryInformation", table.Name))
20 {
21 throw new ArgumentException($"The table {table.Name} is not supported.", "table");
22 }
23
24 foreach (Row row in table.Rows)
25 {
26 this.Add(row);
27 }
28 }
29
30 /// <summary>
31 /// Gets the summary property ID for the <paramref name="row"/>.
32 /// </summary>
33 /// <param name="row">The row to index.</param>
34 /// <returns>The summary property ID for the <paramref name="row"/>.</returns>
35 protected override int GetKeyForItem(Row row)
36 {
37 return (int)row[0];
38 }
39 }
40 }