aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/WixComponentSearchInfo.cs
blob: dfd5d8baf8d65a8bb8129c05ff7104b684257405 (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
// 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
{
    using System;
    using System.Xml;
    using WixToolset.Data;

    /// <summary>
    /// Utility class for all WixComponentSearches.
    /// </summary>
    internal class WixComponentSearchInfo : WixSearchInfo
    {
        public WixComponentSearchInfo(Row row)
            : this((string)row[0], (string)row[1], (string)row[2], (int)row[3])
        {
        }

        public WixComponentSearchInfo(string id, string guid, string productCode, int attributes)
            : base(id)
        {
            this.Guid = guid;
            this.ProductCode = productCode;
            this.Attributes = (WixComponentSearchAttributes)attributes;
        }

        public string Guid { get; private set; }
        public string ProductCode { get; private set; }
        public WixComponentSearchAttributes Attributes { get; private set; }

        /// <summary>
        /// Generates Burn manifest and ParameterInfo-style markup for a component search.
        /// </summary>
        /// <param name="writer"></param>
        public override void WriteXml(XmlTextWriter writer)
        {
            writer.WriteStartElement("MsiComponentSearch");
            this.WriteWixSearchAttributes(writer);

            writer.WriteAttributeString("ComponentId", this.Guid);

            if (!String.IsNullOrEmpty(this.ProductCode))
            {
                writer.WriteAttributeString("ProductCode", this.ProductCode);
            }

            if (0 != (this.Attributes & WixComponentSearchAttributes.KeyPath))
            {
                writer.WriteAttributeString("Type", "keyPath");
            }
            else if (0 != (this.Attributes & WixComponentSearchAttributes.State))
            {
                writer.WriteAttributeString("Type", "state");
            }
            else if (0 != (this.Attributes & WixComponentSearchAttributes.WantDirectory))
            {
                writer.WriteAttributeString("Type", "directory");
            }

            writer.WriteEndElement();
        }
    }

}