diff options
Diffstat (limited to 'src/WixToolset.Data/IntermediateTupleExtensions.cs')
-rw-r--r-- | src/WixToolset.Data/IntermediateTupleExtensions.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/WixToolset.Data/IntermediateTupleExtensions.cs b/src/WixToolset.Data/IntermediateTupleExtensions.cs new file mode 100644 index 00000000..9865c06a --- /dev/null +++ b/src/WixToolset.Data/IntermediateTupleExtensions.cs | |||
@@ -0,0 +1,41 @@ | |||
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.Data | ||
4 | { | ||
5 | public static class IntermediateTupleExtensions | ||
6 | { | ||
7 | public static IntermediateField Set(this IntermediateTuple tuple, int index, object value) | ||
8 | { | ||
9 | var definition = tuple.Definition.FieldDefinitions[index]; | ||
10 | |||
11 | var field = tuple.Fields[index].Set(definition, value); ; | ||
12 | |||
13 | return tuple.Fields[index] = field; | ||
14 | } | ||
15 | |||
16 | public static bool AsBool(this IntermediateTuple tuple, int index) | ||
17 | { | ||
18 | return tuple?.Fields[index].AsBool() ?? false; | ||
19 | } | ||
20 | |||
21 | public static bool? AsNullableBool(this IntermediateTuple tuple, int index) | ||
22 | { | ||
23 | return tuple?.Fields[index].AsNullableBool(); | ||
24 | } | ||
25 | |||
26 | public static int AsNumber(this IntermediateTuple tuple, int index) | ||
27 | { | ||
28 | return tuple?.Fields[index].AsNumber() ?? 0; | ||
29 | } | ||
30 | |||
31 | public static int? AsNullableNumber(this IntermediateTuple tuple, int index) | ||
32 | { | ||
33 | return tuple?.Fields[index].AsNullableNumber(); | ||
34 | } | ||
35 | |||
36 | public static string AsString(this IntermediateTuple tuple, int index) | ||
37 | { | ||
38 | return tuple?.Fields[index].AsString(); | ||
39 | } | ||
40 | } | ||
41 | } | ||