aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs
blob: aef130b025deea8760adba556f123330923af17a (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 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.Core.WindowsInstaller.Databases
{
    using System;
    using System.Collections.Generic;
    using WixToolset.Data;
    using WixToolset.Data.Rows;

    internal class CreateSpecialPropertiesCommand
    {
        public Table PropertyTable { private get; set; }

        public Table WixPropertyTable { private get; set; }

        public void Execute()
        {
            // Create the special properties.
            if (null != this.WixPropertyTable)
            {
                // Create lists of the properties that contribute to the special lists of properties.
                SortedSet<string> adminProperties = new SortedSet<string>();
                SortedSet<string> secureProperties = new SortedSet<string>();
                SortedSet<string> hiddenProperties = new SortedSet<string>();

                foreach (WixPropertyRow wixPropertyRow in this.WixPropertyTable.Rows)
                {
                    if (wixPropertyRow.Admin)
                    {
                        adminProperties.Add(wixPropertyRow.Id);
                    }

                    if (wixPropertyRow.Hidden)
                    {
                        hiddenProperties.Add(wixPropertyRow.Id);
                    }

                    if (wixPropertyRow.Secure)
                    {
                        secureProperties.Add(wixPropertyRow.Id);
                    }
                }

                Table propertyTable = this.PropertyTable;
                if (0 < adminProperties.Count)
                {
                    PropertyRow row = (PropertyRow)propertyTable.CreateRow(null);
                    row.Property = "AdminProperties";
                    row.Value = String.Join(";", adminProperties);
                }

                if (0 < secureProperties.Count)
                {
                    PropertyRow row = (PropertyRow)propertyTable.CreateRow(null);
                    row.Property = "SecureCustomProperties";
                    row.Value = String.Join(";", secureProperties);
                }

                if (0 < hiddenProperties.Count)
                {
                    PropertyRow row = (PropertyRow)propertyTable.CreateRow(null);
                    row.Property = "MsiHiddenProperties";
                    row.Value = String.Join(";", hiddenProperties);
                }
            }
        }
    }
}