aboutsummaryrefslogtreecommitdiff
path: root/src/wixext/Tuples/SqlScriptTuple.cs
blob: 6e4e484b7d4aafdde7468006cd2e838352ea57b9 (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
// 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.Sql
{
    using WixToolset.Data;
    using WixToolset.Sql.Tuples;

    public static partial class SqlTupleDefinitions
    {
        public static readonly IntermediateTupleDefinition SqlScript = new IntermediateTupleDefinition(
            SqlTupleDefinitionType.SqlScript.ToString(),
            new[]
            {
                new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDbRef), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ComponentRef), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinaryRef), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.UserRef), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Attributes), IntermediateFieldType.Number),
                new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Sequence), IntermediateFieldType.Number),
            },
            typeof(SqlScriptTuple));
    }
}

namespace WixToolset.Sql.Tuples
{
    using WixToolset.Data;

    public enum SqlScriptTupleFields
    {
        SqlDbRef,
        ComponentRef,
        ScriptBinaryRef,
        UserRef,
        Attributes,
        Sequence,
    }

    public class SqlScriptTuple : IntermediateTuple
    {
        public SqlScriptTuple() : base(SqlTupleDefinitions.SqlScript, null, null)
        {
        }

        public SqlScriptTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlScript, sourceLineNumber, id)
        {
        }

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

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

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

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

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

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

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