aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/Tuples/WixBundlePatchTargetCodeTuple.cs
blob: 56ca144ffea1dd52b6a8de2e34dbcdbe6a605b88 (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
// 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
{
    using WixToolset.Data.Tuples;

    public static partial class TupleDefinitions
    {
        public static readonly IntermediateTupleDefinition WixBundlePatchTargetCode = new IntermediateTupleDefinition(
            TupleDefinitionType.WixBundlePatchTargetCode,
            new[]
            {
                new IntermediateFieldDefinition(nameof(WixBundlePatchTargetCodeTupleFields.PackageRef), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(WixBundlePatchTargetCodeTupleFields.TargetCode), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(WixBundlePatchTargetCodeTupleFields.Attributes), IntermediateFieldType.Number),
            },
            typeof(WixBundlePatchTargetCodeTuple));
    }
}

namespace WixToolset.Data.Tuples
{
    using System;

    public enum WixBundlePatchTargetCodeTupleFields
    {
        PackageRef,
        TargetCode,
        Attributes,
    }

    [Flags]
    public enum WixBundlePatchTargetCodeAttributes : int
    {
        None = 0,

        /// <summary>
        /// The transform targets a specific ProductCode.
        /// </summary>
        TargetsProductCode = 1,

        /// <summary>
        /// The transform targets a specific UpgradeCode.
        /// </summary>
        TargetsUpgradeCode = 2,
    }

    public class WixBundlePatchTargetCodeTuple : IntermediateTuple
    {
        public WixBundlePatchTargetCodeTuple() : base(TupleDefinitions.WixBundlePatchTargetCode, null, null)
        {
        }

        public WixBundlePatchTargetCodeTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(TupleDefinitions.WixBundlePatchTargetCode, sourceLineNumber, id)
        {
        }

        public IntermediateField this[WixBundlePatchTargetCodeTupleFields index] => this.Fields[(int)index];

        public string PackageRef
        {
            get => (string)this.Fields[(int)WixBundlePatchTargetCodeTupleFields.PackageRef];
            set => this.Set((int)WixBundlePatchTargetCodeTupleFields.PackageRef, value);
        }

        public string TargetCode
        {
            get => (string)this.Fields[(int)WixBundlePatchTargetCodeTupleFields.TargetCode];
            set => this.Set((int)WixBundlePatchTargetCodeTupleFields.TargetCode, value);
        }

        public WixBundlePatchTargetCodeAttributes Attributes
        {
            get => (WixBundlePatchTargetCodeAttributes)this.Fields[(int)WixBundlePatchTargetCodeTupleFields.Attributes].AsNumber();
            set => this.Set((int)WixBundlePatchTargetCodeTupleFields.Attributes, (int)value);
        }

        public bool TargetsProductCode => (this.Attributes & WixBundlePatchTargetCodeAttributes.TargetsProductCode) == WixBundlePatchTargetCodeAttributes.TargetsProductCode;

        public bool TargetsUpgradeCode => (this.Attributes & WixBundlePatchTargetCodeAttributes.TargetsUpgradeCode) == WixBundlePatchTargetCodeAttributes.TargetsUpgradeCode;
    }
}