aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data.WindowsInstaller/Rows/WixPropertyRow.cs
blob: 5285195cd3b10504d141370f8c7b987266516801 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// 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.Globalization;

    /// <summary>
    /// Specialization of a row for the WixProperty table.
    /// </summary>
    public sealed class WixPropertyRow : Row
    {
        /// <summary>Creates a WixProperty row that belongs to a table.</summary>
        /// <param name="sourceLineNumbers">Original source lines for this row.</param>
        /// <param name="table">Table this WixProperty row belongs to and should get its column definitions from.</param>
        public WixPropertyRow(SourceLineNumber sourceLineNumbers, Table table) :
            base(sourceLineNumbers, table)
        {
        }

        /// <summary>
        /// Gets and sets the id for this property row.
        /// </summary>
        /// <value>Id for the property.</value>
        public string Id
        {
            get { return (string)this.Fields[0].Data; }
            set { this.Fields[0].Data = value; }
        }

        /// <summary>
        /// Gets and sets if this is an admin property row.
        /// </summary>
        /// <value>Flag if this is an admin property.</value>
        public bool Admin
        {
            get
            {
                return (0x1 == (Convert.ToInt32(this.Fields[1].Data, CultureInfo.InvariantCulture) & 0x1));
            }

            set
            {
                if (null == this.Fields[1].Data)
                {
                    this.Fields[1].Data = 0;
                }

                if (value)
                {
                    this.Fields[1].Data = (int)this.Fields[1].Data | 0x1;
                }
                else
                {
                    this.Fields[1].Data = (int)this.Fields[1].Data & ~0x1;
                }
            }
        }

        /// <summary>
        /// Gets and sets if this is a hidden property row.
        /// </summary>
        /// <value>Flag if this is a hidden property.</value>
        public bool Hidden
        {
            get
            {
                return (0x2 == (Convert.ToInt32(this.Fields[1].Data, CultureInfo.InvariantCulture) & 0x2));
            }

            set
            {
                if (null == this.Fields[1].Data)
                {
                    this.Fields[1].Data = 0;
                }

                if (value)
                {
                    this.Fields[1].Data = (int)this.Fields[1].Data | 0x2;
                }
                else
                {
                    this.Fields[1].Data = (int)this.Fields[1].Data & ~0x2;
                }
            }
        }

        /// <summary>
        /// Gets and sets if this is a secure property row.
        /// </summary>
        /// <value>Flag if this is a secure property.</value>
        public bool Secure
        {
            get
            {
                return (0x4 == (Convert.ToInt32(this.Fields[1].Data, CultureInfo.InvariantCulture) & 0x4));
            }

            set
            {
                if (null == this.Fields[1].Data)
                {
                    this.Fields[1].Data = 0;
                }

                if (value)
                {
                    this.Fields[1].Data = (int)this.Fields[1].Data | 0x4;
                }
                else
                {
                    this.Fields[1].Data = (int)this.Fields[1].Data & ~0x4;
                }
            }
        }
    }
}