aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/IntermediateTupleDefinition.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-11-01 10:56:09 -0700
committerRob Mensching <rob@firegiant.com>2017-11-01 10:56:09 -0700
commit69b15d96cebdbb7201b1849b4f62786633d70b8d (patch)
tree4b65de8679e4b4ab81b69edcccbac1ae9f55a16d /src/WixToolset.Data/IntermediateTupleDefinition.cs
parenta8656a87887d6cb2c54f4bbeacee37f7074f1032 (diff)
downloadwix-69b15d96cebdbb7201b1849b4f62786633d70b8d.tar.gz
wix-69b15d96cebdbb7201b1849b4f62786633d70b8d.tar.bz2
wix-69b15d96cebdbb7201b1849b4f62786633d70b8d.zip
Introduce WiX Intermediate Representation
Diffstat (limited to 'src/WixToolset.Data/IntermediateTupleDefinition.cs')
-rw-r--r--src/WixToolset.Data/IntermediateTupleDefinition.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/WixToolset.Data/IntermediateTupleDefinition.cs b/src/WixToolset.Data/IntermediateTupleDefinition.cs
new file mode 100644
index 00000000..5658cfe9
--- /dev/null
+++ b/src/WixToolset.Data/IntermediateTupleDefinition.cs
@@ -0,0 +1,47 @@
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
3namespace WixToolset.Data
4{
5 using System;
6
7 public class IntermediateTupleDefinition
8 {
9 public IntermediateTupleDefinition(string name, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType)
10 : this(TupleDefinitionType.MustBeFromAnExtension, name, fieldDefinitions, strongTupleType)
11 {
12 }
13
14 internal IntermediateTupleDefinition(TupleDefinitionType type, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType)
15 : this(type, type.ToString(), fieldDefinitions, strongTupleType)
16 {
17 }
18
19 private IntermediateTupleDefinition(TupleDefinitionType type, string name, IntermediateFieldDefinition[] fieldDefinitions, Type strongTupleType)
20 {
21 this.Type = type;
22 this.Name = name;
23 this.FieldDefinitions = fieldDefinitions;
24 this.StrongTupleType = strongTupleType ?? typeof(IntermediateTuple);
25#if DEBUG
26 if (!this.StrongTupleType.IsSubclassOf(typeof(IntermediateTuple))) throw new ArgumentException(nameof(strongTupleType));
27#endif
28 }
29
30 public TupleDefinitionType Type { get; }
31
32 public string Name { get; }
33
34 public IntermediateFieldDefinition[] FieldDefinitions { get; }
35
36 private Type StrongTupleType { get; }
37
38 public IntermediateTuple CreateTuple(SourceLineNumber sourceLineNumber = null, Identifier id = null)
39 {
40 var result = (this.StrongTupleType == typeof(IntermediateTuple)) ? (IntermediateTuple)Activator.CreateInstance(this.StrongTupleType, this) : (IntermediateTuple)Activator.CreateInstance(this.StrongTupleType);
41 result.SourceLineNumbers = sourceLineNumber;
42 result.Id = id;
43
44 return result;
45 }
46 }
47}