aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/Tuples/EnvironmentTuple.cs
blob: 98c51f4db56c6ac073f5be6c54ab4ceb0a75995e (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
// 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 Environment = new IntermediateTupleDefinition(
            TupleDefinitionType.Environment,
            new[]
            {
                new IntermediateFieldDefinition(nameof(EnvironmentTupleFields.Name), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(EnvironmentTupleFields.Value), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(EnvironmentTupleFields.Separator), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(EnvironmentTupleFields.Action), IntermediateFieldType.Number),
                new IntermediateFieldDefinition(nameof(EnvironmentTupleFields.Part), IntermediateFieldType.Number),
                new IntermediateFieldDefinition(nameof(EnvironmentTupleFields.Permanent), IntermediateFieldType.Bool),
                new IntermediateFieldDefinition(nameof(EnvironmentTupleFields.System), IntermediateFieldType.Bool),
                new IntermediateFieldDefinition(nameof(EnvironmentTupleFields.ComponentRef), IntermediateFieldType.String),
            },
            typeof(EnvironmentTuple));
    }
}

namespace WixToolset.Data.Tuples
{
    public enum EnvironmentTupleFields
    {
        Name,
        Value,
        Separator,
        Action,
        Part,
        Permanent,
        System,
        ComponentRef,
    }

    public enum EnvironmentActionType
    {
        Set,
        Create,
        Remove
    }

    public enum EnvironmentPartType
    {
        All,
        First,
        Last
    }

    public class EnvironmentTuple : IntermediateTuple
    {
        public EnvironmentTuple() : base(TupleDefinitions.Environment, null, null)
        {
        }

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

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

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

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

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

        public EnvironmentActionType? Action
        {
            get => (EnvironmentActionType?)this.Fields[(int)EnvironmentTupleFields.Action].AsNullableNumber();
            set => this.Set((int)EnvironmentTupleFields.Action, (int?)value);
        }

        public EnvironmentPartType? Part
        {
            get => (EnvironmentPartType?)this.Fields[(int)EnvironmentTupleFields.Part].AsNullableNumber();
            set => this.Set((int)EnvironmentTupleFields.Part, (int?)value);
        }

        public bool Permanent
        {
            get => this.Fields[(int)EnvironmentTupleFields.Permanent].AsBool();
            set => this.Set((int)EnvironmentTupleFields.Permanent, value);
        }

        public bool System
        {
            get => this.Fields[(int)EnvironmentTupleFields.System].AsBool();
            set => this.Set((int)EnvironmentTupleFields.System, value);
        }

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