diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2019-01-02 22:33:22 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2019-01-02 22:33:22 -0600 |
commit | 2dcc519054be041ef5aa6cfac9dac13b0ea04eca (patch) | |
tree | ba530ef5d4add27c9727d96d46809d6f1c426b3f | |
parent | 6a497dc3559b8a5283405a1e1456af6a4c0bbdde (diff) | |
download | wix-2dcc519054be041ef5aa6cfac9dac13b0ea04eca.tar.gz wix-2dcc519054be041ef5aa6cfac9dac13b0ea04eca.tar.bz2 wix-2dcc519054be041ef5aa6cfac9dac13b0ea04eca.zip |
Add tuple definitions and fix test.
-rw-r--r-- | src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | 2 | ||||
-rw-r--r-- | src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs | 4 | ||||
-rw-r--r-- | src/wixext/SqlCompiler.cs | 8 | ||||
-rw-r--r-- | src/wixext/SqlExtensionData.cs | 2 | ||||
-rw-r--r-- | src/wixext/Tuples/SqlDatabaseTuple.cs | 111 | ||||
-rw-r--r-- | src/wixext/Tuples/SqlFileSpecTuple.cs | 87 | ||||
-rw-r--r-- | src/wixext/Tuples/SqlScriptTuple.cs | 95 | ||||
-rw-r--r-- | src/wixext/Tuples/SqlStringTuple.cs | 95 | ||||
-rw-r--r-- | src/wixext/Tuples/SqlTupleDefinitions.cs | 51 |
9 files changed, 447 insertions, 8 deletions
diff --git a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs index 831bcd83..d7fe74e6 100644 --- a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs +++ b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | |||
@@ -19,7 +19,7 @@ namespace WixToolsetTest.Sql | |||
19 | var results = build.BuildAndQuery(Build, "SqlString"); | 19 | var results = build.BuildAndQuery(Build, "SqlString"); |
20 | Assert.Equal(new[] | 20 | Assert.Equal(new[] |
21 | { | 21 | { |
22 | "SqlString:", | 22 | "SqlString:TestString\tTestDB\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t0", |
23 | }, results.OrderBy(s => s).ToArray()); | 23 | }, results.OrderBy(s => s).ToArray()); |
24 | } | 24 | } |
25 | 25 | ||
diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs b/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs index d2572659..653f7e02 100644 --- a/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs +++ b/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs | |||
@@ -3,8 +3,8 @@ | |||
3 | xmlns:sql="http://wixtoolset.org/schemas/v4/wxs/sql"> | 3 | xmlns:sql="http://wixtoolset.org/schemas/v4/wxs/sql"> |
4 | <Fragment> | 4 | <Fragment> |
5 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | 5 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> |
6 | <Component KeyPath="yes"> | 6 | <Component> |
7 | <CreateFolder /> | 7 | <File Source="example.txt" /> |
8 | <sql:SqlDatabase Id="TestDB" Database="MyDB" Server="MySQLHostName" Instance="MyInstanceName" CreateOnInstall="yes" DropOnUninstall="yes" ConfirmOverwrite="yes"> | 8 | <sql:SqlDatabase Id="TestDB" Database="MyDB" Server="MySQLHostName" Instance="MyInstanceName" CreateOnInstall="yes" DropOnUninstall="yes" ConfirmOverwrite="yes"> |
9 | <sql:SqlString Id="TestString" SQL="CREATE TABLE TestTable1(name varchar(20), value varchar(20))" ExecuteOnInstall="yes" /> | 9 | <sql:SqlString Id="TestString" SQL="CREATE TABLE TestTable1(name varchar(20), value varchar(20))" ExecuteOnInstall="yes" /> |
10 | </sql:SqlDatabase> | 10 | </sql:SqlDatabase> |
diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index c789f3bd..3fb33993 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs | |||
@@ -265,7 +265,7 @@ namespace WixToolset.Sql | |||
265 | this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); | 265 | this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); |
266 | } | 266 | } |
267 | 267 | ||
268 | this.ParseSqlScriptElement(intermediate, section, child, componentId, id.Id); | 268 | this.ParseSqlScriptElement(intermediate, section, child, componentId, id?.Id); |
269 | break; | 269 | break; |
270 | case "SqlString": | 270 | case "SqlString": |
271 | if (null == componentId) | 271 | if (null == componentId) |
@@ -273,7 +273,7 @@ namespace WixToolset.Sql | |||
273 | this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); | 273 | this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); |
274 | } | 274 | } |
275 | 275 | ||
276 | this.ParseSqlStringElement(intermediate, section, child, componentId, id.Id); | 276 | this.ParseSqlStringElement(intermediate, section, child, componentId, id?.Id); |
277 | break; | 277 | break; |
278 | case "SqlFileSpec": | 278 | case "SqlFileSpec": |
279 | if (null == componentId) | 279 | if (null == componentId) |
@@ -325,8 +325,8 @@ namespace WixToolset.Sql | |||
325 | row.Set(3, database); | 325 | row.Set(3, database); |
326 | row.Set(4, componentId); | 326 | row.Set(4, componentId); |
327 | row.Set(5, user); | 327 | row.Set(5, user); |
328 | row.Set(6, fileSpec.Id); | 328 | row.Set(6, fileSpec?.Id); |
329 | row.Set(7, logFileSpec.Id); | 329 | row.Set(7, logFileSpec?.Id); |
330 | if (0 != attributes) | 330 | if (0 != attributes) |
331 | { | 331 | { |
332 | row.Set(8, attributes); | 332 | row.Set(8, attributes); |
diff --git a/src/wixext/SqlExtensionData.cs b/src/wixext/SqlExtensionData.cs index a1b24b07..e27b698f 100644 --- a/src/wixext/SqlExtensionData.cs +++ b/src/wixext/SqlExtensionData.cs | |||
@@ -18,7 +18,7 @@ namespace WixToolset.Sql | |||
18 | 18 | ||
19 | public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) | 19 | public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) |
20 | { | 20 | { |
21 | tupleDefinition = null; | 21 | tupleDefinition = SqlTupleDefinitions.ByName(name); |
22 | return tupleDefinition != null; | 22 | return tupleDefinition != null; |
23 | } | 23 | } |
24 | 24 | ||
diff --git a/src/wixext/Tuples/SqlDatabaseTuple.cs b/src/wixext/Tuples/SqlDatabaseTuple.cs new file mode 100644 index 00000000..fd107690 --- /dev/null +++ b/src/wixext/Tuples/SqlDatabaseTuple.cs | |||
@@ -0,0 +1,111 @@ | |||
1 | // 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. | ||
2 | |||
3 | namespace WixToolset.Sql | ||
4 | { | ||
5 | using WixToolset.Data; | ||
6 | using WixToolset.Sql.Tuples; | ||
7 | |||
8 | public static partial class SqlTupleDefinitions | ||
9 | { | ||
10 | public static readonly IntermediateTupleDefinition SqlDatabase = new IntermediateTupleDefinition( | ||
11 | SqlTupleDefinitionType.SqlDatabase.ToString(), | ||
12 | new[] | ||
13 | { | ||
14 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.SqlDb), IntermediateFieldType.String), | ||
15 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Server), IntermediateFieldType.String), | ||
16 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Instance), IntermediateFieldType.String), | ||
17 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Database), IntermediateFieldType.String), | ||
18 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Component_), IntermediateFieldType.String), | ||
19 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.User_), IntermediateFieldType.String), | ||
20 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_), IntermediateFieldType.String), | ||
21 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_Log), IntermediateFieldType.String), | ||
22 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Attributes), IntermediateFieldType.Number), | ||
23 | }, | ||
24 | typeof(SqlDatabaseTuple)); | ||
25 | } | ||
26 | } | ||
27 | |||
28 | namespace WixToolset.Sql.Tuples | ||
29 | { | ||
30 | using WixToolset.Data; | ||
31 | |||
32 | public enum SqlDatabaseTupleFields | ||
33 | { | ||
34 | SqlDb, | ||
35 | Server, | ||
36 | Instance, | ||
37 | Database, | ||
38 | Component_, | ||
39 | User_, | ||
40 | FileSpec_, | ||
41 | FileSpec_Log, | ||
42 | Attributes, | ||
43 | } | ||
44 | |||
45 | public class SqlDatabaseTuple : IntermediateTuple | ||
46 | { | ||
47 | public SqlDatabaseTuple() : base(SqlTupleDefinitions.SqlDatabase, null, null) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | public SqlDatabaseTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlDatabase, sourceLineNumber, id) | ||
52 | { | ||
53 | } | ||
54 | |||
55 | public IntermediateField this[SqlDatabaseTupleFields index] => this.Fields[(int)index]; | ||
56 | |||
57 | public string SqlDb | ||
58 | { | ||
59 | get => this.Fields[(int)SqlDatabaseTupleFields.SqlDb].AsString(); | ||
60 | set => this.Set((int)SqlDatabaseTupleFields.SqlDb, value); | ||
61 | } | ||
62 | |||
63 | public string Server | ||
64 | { | ||
65 | get => this.Fields[(int)SqlDatabaseTupleFields.Server].AsString(); | ||
66 | set => this.Set((int)SqlDatabaseTupleFields.Server, value); | ||
67 | } | ||
68 | |||
69 | public string Instance | ||
70 | { | ||
71 | get => this.Fields[(int)SqlDatabaseTupleFields.Instance].AsString(); | ||
72 | set => this.Set((int)SqlDatabaseTupleFields.Instance, value); | ||
73 | } | ||
74 | |||
75 | public string Database | ||
76 | { | ||
77 | get => this.Fields[(int)SqlDatabaseTupleFields.Database].AsString(); | ||
78 | set => this.Set((int)SqlDatabaseTupleFields.Database, value); | ||
79 | } | ||
80 | |||
81 | public string Component_ | ||
82 | { | ||
83 | get => this.Fields[(int)SqlDatabaseTupleFields.Component_].AsString(); | ||
84 | set => this.Set((int)SqlDatabaseTupleFields.Component_, value); | ||
85 | } | ||
86 | |||
87 | public string User_ | ||
88 | { | ||
89 | get => this.Fields[(int)SqlDatabaseTupleFields.User_].AsString(); | ||
90 | set => this.Set((int)SqlDatabaseTupleFields.User_, value); | ||
91 | } | ||
92 | |||
93 | public string FileSpec_ | ||
94 | { | ||
95 | get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_].AsString(); | ||
96 | set => this.Set((int)SqlDatabaseTupleFields.FileSpec_, value); | ||
97 | } | ||
98 | |||
99 | public string FileSpec_Log | ||
100 | { | ||
101 | get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_Log].AsString(); | ||
102 | set => this.Set((int)SqlDatabaseTupleFields.FileSpec_Log, value); | ||
103 | } | ||
104 | |||
105 | public int Attributes | ||
106 | { | ||
107 | get => this.Fields[(int)SqlDatabaseTupleFields.Attributes].AsNumber(); | ||
108 | set => this.Set((int)SqlDatabaseTupleFields.Attributes, value); | ||
109 | } | ||
110 | } | ||
111 | } \ No newline at end of file | ||
diff --git a/src/wixext/Tuples/SqlFileSpecTuple.cs b/src/wixext/Tuples/SqlFileSpecTuple.cs new file mode 100644 index 00000000..9813ec83 --- /dev/null +++ b/src/wixext/Tuples/SqlFileSpecTuple.cs | |||
@@ -0,0 +1,87 @@ | |||
1 | // 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. | ||
2 | |||
3 | namespace WixToolset.Sql | ||
4 | { | ||
5 | using WixToolset.Data; | ||
6 | using WixToolset.Sql.Tuples; | ||
7 | |||
8 | public static partial class SqlTupleDefinitions | ||
9 | { | ||
10 | public static readonly IntermediateTupleDefinition SqlFileSpec = new IntermediateTupleDefinition( | ||
11 | SqlTupleDefinitionType.SqlFileSpec.ToString(), | ||
12 | new[] | ||
13 | { | ||
14 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.FileSpec), IntermediateFieldType.String), | ||
15 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Name), IntermediateFieldType.String), | ||
16 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Filename), IntermediateFieldType.String), | ||
17 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Size), IntermediateFieldType.String), | ||
18 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.MaxSize), IntermediateFieldType.String), | ||
19 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.GrowthSize), IntermediateFieldType.String), | ||
20 | }, | ||
21 | typeof(SqlFileSpecTuple)); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | namespace WixToolset.Sql.Tuples | ||
26 | { | ||
27 | using WixToolset.Data; | ||
28 | |||
29 | public enum SqlFileSpecTupleFields | ||
30 | { | ||
31 | FileSpec, | ||
32 | Name, | ||
33 | Filename, | ||
34 | Size, | ||
35 | MaxSize, | ||
36 | GrowthSize, | ||
37 | } | ||
38 | |||
39 | public class SqlFileSpecTuple : IntermediateTuple | ||
40 | { | ||
41 | public SqlFileSpecTuple() : base(SqlTupleDefinitions.SqlFileSpec, null, null) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public SqlFileSpecTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlFileSpec, sourceLineNumber, id) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | public IntermediateField this[SqlFileSpecTupleFields index] => this.Fields[(int)index]; | ||
50 | |||
51 | public string FileSpec | ||
52 | { | ||
53 | get => this.Fields[(int)SqlFileSpecTupleFields.FileSpec].AsString(); | ||
54 | set => this.Set((int)SqlFileSpecTupleFields.FileSpec, value); | ||
55 | } | ||
56 | |||
57 | public string Name | ||
58 | { | ||
59 | get => this.Fields[(int)SqlFileSpecTupleFields.Name].AsString(); | ||
60 | set => this.Set((int)SqlFileSpecTupleFields.Name, value); | ||
61 | } | ||
62 | |||
63 | public string Filename | ||
64 | { | ||
65 | get => this.Fields[(int)SqlFileSpecTupleFields.Filename].AsString(); | ||
66 | set => this.Set((int)SqlFileSpecTupleFields.Filename, value); | ||
67 | } | ||
68 | |||
69 | public string Size | ||
70 | { | ||
71 | get => this.Fields[(int)SqlFileSpecTupleFields.Size].AsString(); | ||
72 | set => this.Set((int)SqlFileSpecTupleFields.Size, value); | ||
73 | } | ||
74 | |||
75 | public string MaxSize | ||
76 | { | ||
77 | get => this.Fields[(int)SqlFileSpecTupleFields.MaxSize].AsString(); | ||
78 | set => this.Set((int)SqlFileSpecTupleFields.MaxSize, value); | ||
79 | } | ||
80 | |||
81 | public string GrowthSize | ||
82 | { | ||
83 | get => this.Fields[(int)SqlFileSpecTupleFields.GrowthSize].AsString(); | ||
84 | set => this.Set((int)SqlFileSpecTupleFields.GrowthSize, value); | ||
85 | } | ||
86 | } | ||
87 | } \ No newline at end of file | ||
diff --git a/src/wixext/Tuples/SqlScriptTuple.cs b/src/wixext/Tuples/SqlScriptTuple.cs new file mode 100644 index 00000000..b1f95709 --- /dev/null +++ b/src/wixext/Tuples/SqlScriptTuple.cs | |||
@@ -0,0 +1,95 @@ | |||
1 | // 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. | ||
2 | |||
3 | namespace WixToolset.Sql | ||
4 | { | ||
5 | using WixToolset.Data; | ||
6 | using WixToolset.Sql.Tuples; | ||
7 | |||
8 | public static partial class SqlTupleDefinitions | ||
9 | { | ||
10 | public static readonly IntermediateTupleDefinition SqlScript = new IntermediateTupleDefinition( | ||
11 | SqlTupleDefinitionType.SqlScript.ToString(), | ||
12 | new[] | ||
13 | { | ||
14 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Script), IntermediateFieldType.String), | ||
15 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDb_), IntermediateFieldType.String), | ||
16 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Component_), IntermediateFieldType.String), | ||
17 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinary_), IntermediateFieldType.String), | ||
18 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.User_), IntermediateFieldType.String), | ||
19 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Attributes), IntermediateFieldType.Number), | ||
20 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Sequence), IntermediateFieldType.Number), | ||
21 | }, | ||
22 | typeof(SqlScriptTuple)); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | namespace WixToolset.Sql.Tuples | ||
27 | { | ||
28 | using WixToolset.Data; | ||
29 | |||
30 | public enum SqlScriptTupleFields | ||
31 | { | ||
32 | Script, | ||
33 | SqlDb_, | ||
34 | Component_, | ||
35 | ScriptBinary_, | ||
36 | User_, | ||
37 | Attributes, | ||
38 | Sequence, | ||
39 | } | ||
40 | |||
41 | public class SqlScriptTuple : IntermediateTuple | ||
42 | { | ||
43 | public SqlScriptTuple() : base(SqlTupleDefinitions.SqlScript, null, null) | ||
44 | { | ||
45 | } | ||
46 | |||
47 | public SqlScriptTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlScript, sourceLineNumber, id) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | public IntermediateField this[SqlScriptTupleFields index] => this.Fields[(int)index]; | ||
52 | |||
53 | public string Script | ||
54 | { | ||
55 | get => this.Fields[(int)SqlScriptTupleFields.Script].AsString(); | ||
56 | set => this.Set((int)SqlScriptTupleFields.Script, value); | ||
57 | } | ||
58 | |||
59 | public string SqlDb_ | ||
60 | { | ||
61 | get => this.Fields[(int)SqlScriptTupleFields.SqlDb_].AsString(); | ||
62 | set => this.Set((int)SqlScriptTupleFields.SqlDb_, value); | ||
63 | } | ||
64 | |||
65 | public string Component_ | ||
66 | { | ||
67 | get => this.Fields[(int)SqlScriptTupleFields.Component_].AsString(); | ||
68 | set => this.Set((int)SqlScriptTupleFields.Component_, value); | ||
69 | } | ||
70 | |||
71 | public string ScriptBinary_ | ||
72 | { | ||
73 | get => this.Fields[(int)SqlScriptTupleFields.ScriptBinary_].AsString(); | ||
74 | set => this.Set((int)SqlScriptTupleFields.ScriptBinary_, value); | ||
75 | } | ||
76 | |||
77 | public string User_ | ||
78 | { | ||
79 | get => this.Fields[(int)SqlScriptTupleFields.User_].AsString(); | ||
80 | set => this.Set((int)SqlScriptTupleFields.User_, value); | ||
81 | } | ||
82 | |||
83 | public int Attributes | ||
84 | { | ||
85 | get => this.Fields[(int)SqlScriptTupleFields.Attributes].AsNumber(); | ||
86 | set => this.Set((int)SqlScriptTupleFields.Attributes, value); | ||
87 | } | ||
88 | |||
89 | public int Sequence | ||
90 | { | ||
91 | get => this.Fields[(int)SqlScriptTupleFields.Sequence].AsNumber(); | ||
92 | set => this.Set((int)SqlScriptTupleFields.Sequence, value); | ||
93 | } | ||
94 | } | ||
95 | } \ No newline at end of file | ||
diff --git a/src/wixext/Tuples/SqlStringTuple.cs b/src/wixext/Tuples/SqlStringTuple.cs new file mode 100644 index 00000000..d2cba0e0 --- /dev/null +++ b/src/wixext/Tuples/SqlStringTuple.cs | |||
@@ -0,0 +1,95 @@ | |||
1 | // 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. | ||
2 | |||
3 | namespace WixToolset.Sql | ||
4 | { | ||
5 | using WixToolset.Data; | ||
6 | using WixToolset.Sql.Tuples; | ||
7 | |||
8 | public static partial class SqlTupleDefinitions | ||
9 | { | ||
10 | public static readonly IntermediateTupleDefinition SqlString = new IntermediateTupleDefinition( | ||
11 | SqlTupleDefinitionType.SqlString.ToString(), | ||
12 | new[] | ||
13 | { | ||
14 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.String), IntermediateFieldType.String), | ||
15 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SqlDb_), IntermediateFieldType.String), | ||
16 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Component_), IntermediateFieldType.String), | ||
17 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SQL), IntermediateFieldType.String), | ||
18 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.User_), IntermediateFieldType.String), | ||
19 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Attributes), IntermediateFieldType.Number), | ||
20 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Sequence), IntermediateFieldType.Number), | ||
21 | }, | ||
22 | typeof(SqlStringTuple)); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | namespace WixToolset.Sql.Tuples | ||
27 | { | ||
28 | using WixToolset.Data; | ||
29 | |||
30 | public enum SqlStringTupleFields | ||
31 | { | ||
32 | String, | ||
33 | SqlDb_, | ||
34 | Component_, | ||
35 | SQL, | ||
36 | User_, | ||
37 | Attributes, | ||
38 | Sequence, | ||
39 | } | ||
40 | |||
41 | public class SqlStringTuple : IntermediateTuple | ||
42 | { | ||
43 | public SqlStringTuple() : base(SqlTupleDefinitions.SqlString, null, null) | ||
44 | { | ||
45 | } | ||
46 | |||
47 | public SqlStringTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlString, sourceLineNumber, id) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | public IntermediateField this[SqlStringTupleFields index] => this.Fields[(int)index]; | ||
52 | |||
53 | public string String | ||
54 | { | ||
55 | get => this.Fields[(int)SqlStringTupleFields.String].AsString(); | ||
56 | set => this.Set((int)SqlStringTupleFields.String, value); | ||
57 | } | ||
58 | |||
59 | public string SqlDb_ | ||
60 | { | ||
61 | get => this.Fields[(int)SqlStringTupleFields.SqlDb_].AsString(); | ||
62 | set => this.Set((int)SqlStringTupleFields.SqlDb_, value); | ||
63 | } | ||
64 | |||
65 | public string Component_ | ||
66 | { | ||
67 | get => this.Fields[(int)SqlStringTupleFields.Component_].AsString(); | ||
68 | set => this.Set((int)SqlStringTupleFields.Component_, value); | ||
69 | } | ||
70 | |||
71 | public string SQL | ||
72 | { | ||
73 | get => this.Fields[(int)SqlStringTupleFields.SQL].AsString(); | ||
74 | set => this.Set((int)SqlStringTupleFields.SQL, value); | ||
75 | } | ||
76 | |||
77 | public string User_ | ||
78 | { | ||
79 | get => this.Fields[(int)SqlStringTupleFields.User_].AsString(); | ||
80 | set => this.Set((int)SqlStringTupleFields.User_, value); | ||
81 | } | ||
82 | |||
83 | public int Attributes | ||
84 | { | ||
85 | get => this.Fields[(int)SqlStringTupleFields.Attributes].AsNumber(); | ||
86 | set => this.Set((int)SqlStringTupleFields.Attributes, value); | ||
87 | } | ||
88 | |||
89 | public int Sequence | ||
90 | { | ||
91 | get => this.Fields[(int)SqlStringTupleFields.Sequence].AsNumber(); | ||
92 | set => this.Set((int)SqlStringTupleFields.Sequence, value); | ||
93 | } | ||
94 | } | ||
95 | } \ No newline at end of file | ||
diff --git a/src/wixext/Tuples/SqlTupleDefinitions.cs b/src/wixext/Tuples/SqlTupleDefinitions.cs new file mode 100644 index 00000000..b99b96a7 --- /dev/null +++ b/src/wixext/Tuples/SqlTupleDefinitions.cs | |||
@@ -0,0 +1,51 @@ | |||
1 | // 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. | ||
2 | |||
3 | namespace WixToolset.Sql | ||
4 | { | ||
5 | using System; | ||
6 | using WixToolset.Data; | ||
7 | |||
8 | public enum SqlTupleDefinitionType | ||
9 | { | ||
10 | SqlDatabase, | ||
11 | SqlFileSpec, | ||
12 | SqlScript, | ||
13 | SqlString, | ||
14 | } | ||
15 | |||
16 | public static partial class SqlTupleDefinitions | ||
17 | { | ||
18 | public static readonly Version Version = new Version("4.0.0"); | ||
19 | |||
20 | public static IntermediateTupleDefinition ByName(string name) | ||
21 | { | ||
22 | if (!Enum.TryParse(name, out SqlTupleDefinitionType type)) | ||
23 | { | ||
24 | return null; | ||
25 | } | ||
26 | |||
27 | return ByType(type); | ||
28 | } | ||
29 | |||
30 | public static IntermediateTupleDefinition ByType(SqlTupleDefinitionType type) | ||
31 | { | ||
32 | switch (type) | ||
33 | { | ||
34 | case SqlTupleDefinitionType.SqlDatabase: | ||
35 | return SqlTupleDefinitions.SqlDatabase; | ||
36 | |||
37 | case SqlTupleDefinitionType.SqlFileSpec: | ||
38 | return SqlTupleDefinitions.SqlFileSpec; | ||
39 | |||
40 | case SqlTupleDefinitionType.SqlScript: | ||
41 | return SqlTupleDefinitions.SqlScript; | ||
42 | |||
43 | case SqlTupleDefinitionType.SqlString: | ||
44 | return SqlTupleDefinitions.SqlString; | ||
45 | |||
46 | default: | ||
47 | throw new ArgumentOutOfRangeException(nameof(type)); | ||
48 | } | ||
49 | } | ||
50 | } | ||
51 | } | ||