aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data.WindowsInstaller/Rows/SummaryInfoRowCollection.cs
blob: bc931f1589f59d6ea7b32ce787f8dc2ac419a86c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// 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.

namespace WixToolset.Data.Rows
{
    using System;
    using System.Collections;
    using System.Collections.ObjectModel;

    /// <summary>
    /// Indexed container class for summary information rows.
    /// </summary>
    public sealed class SummaryInfoRowCollection : KeyedCollection<int, Row>
    {
        /// <summary>
        /// Creates the keyed collection from existing rows in a table.
        /// </summary>
        /// <param name="table">The summary information table to index.</param>
        public SummaryInfoRowCollection(Table table)
        {
            if (0 != String.CompareOrdinal("_SummaryInformation", table.Name))
            {
                string message = string.Format(WixDataStrings.EXP_UnsupportedTable, table.Name);
                throw new ArgumentException(message, "table");
            }

            foreach (Row row in table.Rows)
            {
                this.Add(row);
            }
        }

        /// <summary>
        /// Gets the summary property ID for the <paramref name="row"/>.
        /// </summary>
        /// <param name="row">The row to index.</param>
        /// <returns>The summary property ID for the <paramref name="row"/>.
        protected override int GetKeyForItem(Row row)
        {
            return (int)row[0];
        }
    }
}