summaryrefslogtreecommitdiff
path: root/src/ext/Sql/wixext/Symbols/SqlScriptSymbol.cs
blob: 94c703908014c5677248a87a1c030691e96d41bb (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.Symbols;

    public static partial class SqlSymbolDefinitions
    {
        public static readonly IntermediateSymbolDefinition SqlScript = new IntermediateSymbolDefinition(
            SqlSymbolDefinitionType.SqlScript.ToString(),
            new[]
            {
                new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.SqlDbRef), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ComponentRef), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ScriptBinaryRef), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.UserRef), IntermediateFieldType.String),
                new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Attributes), IntermediateFieldType.Number),
                new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Sequence), IntermediateFieldType.Number),
            },
            typeof(SqlScriptSymbol));
    }
}

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

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

    public class SqlScriptSymbol : IntermediateSymbol
    {
        public SqlScriptSymbol() : base(SqlSymbolDefinitions.SqlScript, null, null)
        {
        }

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

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

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

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

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

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

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

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