aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/IntermediateTupleDefinition.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/WixToolset.Data/IntermediateTupleDefinition.cs24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/WixToolset.Data/IntermediateTupleDefinition.cs b/src/WixToolset.Data/IntermediateTupleDefinition.cs
index eb4ab12e..ea15c2dd 100644
--- a/src/WixToolset.Data/IntermediateTupleDefinition.cs
+++ b/src/WixToolset.Data/IntermediateTupleDefinition.cs
@@ -1,4 +1,4 @@
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. 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 2
3namespace WixToolset.Data 3namespace WixToolset.Data
4{ 4{
@@ -8,19 +8,25 @@ namespace WixToolset.Data
8 public class IntermediateTupleDefinition 8 public class IntermediateTupleDefinition
9 { 9 {
10 public IntermediateTupleDefinition(string name, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType) 10 public IntermediateTupleDefinition(string name, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType)
11 : this(TupleDefinitionType.MustBeFromAnExtension, name, fieldDefinitions, strongTupleType) 11 : this(TupleDefinitionType.MustBeFromAnExtension, name, 0, fieldDefinitions, strongTupleType)
12 {
13 }
14
15 public IntermediateTupleDefinition(string name, int revision, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType)
16 : this(TupleDefinitionType.MustBeFromAnExtension, name, revision, fieldDefinitions, strongTupleType)
12 { 17 {
13 } 18 }
14 19
15 internal IntermediateTupleDefinition(TupleDefinitionType type, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType) 20 internal IntermediateTupleDefinition(TupleDefinitionType type, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType)
16 : this(type, type.ToString(), fieldDefinitions, strongTupleType) 21 : this(type, type.ToString(), 0, fieldDefinitions, strongTupleType)
17 { 22 {
18 } 23 }
19 24
20 private IntermediateTupleDefinition(TupleDefinitionType type, string name, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType) 25 private IntermediateTupleDefinition(TupleDefinitionType type, string name, int revision, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType)
21 { 26 {
22 this.Type = type; 27 this.Type = type;
23 this.Name = name; 28 this.Name = name;
29 this.Revision = revision;
24 this.FieldDefinitions = fieldDefinitions; 30 this.FieldDefinitions = fieldDefinitions;
25 this.StrongTupleType = strongTupleType ?? typeof(IntermediateTuple); 31 this.StrongTupleType = strongTupleType ?? typeof(IntermediateTuple);
26#if DEBUG 32#if DEBUG
@@ -28,6 +34,8 @@ namespace WixToolset.Data
28#endif 34#endif
29 } 35 }
30 36
37 public int Revision { get; }
38
31 public TupleDefinitionType Type { get; } 39 public TupleDefinitionType Type { get; }
32 40
33 public string Name { get; } 41 public string Name { get; }
@@ -48,6 +56,7 @@ namespace WixToolset.Data
48 internal static IntermediateTupleDefinition Deserialize(JsonObject jsonObject) 56 internal static IntermediateTupleDefinition Deserialize(JsonObject jsonObject)
49 { 57 {
50 var name = jsonObject.GetValueOrDefault<string>("name"); 58 var name = jsonObject.GetValueOrDefault<string>("name");
59 var revision = jsonObject.GetValueOrDefault("rev", 0);
51 var definitionsJson = jsonObject.GetValueOrDefault<JsonArray>("fields"); 60 var definitionsJson = jsonObject.GetValueOrDefault<JsonArray>("fields");
52 61
53 var fieldDefinitions = new IntermediateFieldDefinition[definitionsJson.Count]; 62 var fieldDefinitions = new IntermediateFieldDefinition[definitionsJson.Count];
@@ -60,7 +69,7 @@ namespace WixToolset.Data
60 fieldDefinitions[i] = new IntermediateFieldDefinition(fieldName, fieldType); 69 fieldDefinitions[i] = new IntermediateFieldDefinition(fieldName, fieldType);
61 } 70 }
62 71
63 return new IntermediateTupleDefinition(name, fieldDefinitions, null); 72 return new IntermediateTupleDefinition(name, revision, fieldDefinitions, null);
64 } 73 }
65 74
66 internal JsonObject Serialize() 75 internal JsonObject Serialize()
@@ -70,6 +79,11 @@ namespace WixToolset.Data
70 { "name", this.Name } 79 { "name", this.Name }
71 }; 80 };
72 81
82 if (this.Revision > 0)
83 {
84 jsonObject.Add("rev", this.Revision);
85 }
86
73 var fieldsJson = new JsonArray(this.FieldDefinitions.Length); 87 var fieldsJson = new JsonArray(this.FieldDefinitions.Length);
74 88
75 foreach (var fieldDefinition in this.FieldDefinitions) 89 foreach (var fieldDefinition in this.FieldDefinitions)