diff options
Diffstat (limited to 'src/WixToolset.Data/IntermediateFieldValueExtensions.cs')
-rw-r--r-- | src/WixToolset.Data/IntermediateFieldValueExtensions.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/WixToolset.Data/IntermediateFieldValueExtensions.cs b/src/WixToolset.Data/IntermediateFieldValueExtensions.cs new file mode 100644 index 00000000..bc106d4b --- /dev/null +++ b/src/WixToolset.Data/IntermediateFieldValueExtensions.cs | |||
@@ -0,0 +1,37 @@ | |||
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 IntermediateFieldValueExtensions | ||
6 | { | ||
7 | public static bool AsBool(this IntermediateFieldValue value) | ||
8 | { | ||
9 | return value?.Data == null ? false : (bool)value.Data; | ||
10 | } | ||
11 | |||
12 | public static bool? AsNullableBool(this IntermediateFieldValue value) | ||
13 | { | ||
14 | return (bool?)value?.Data; | ||
15 | } | ||
16 | |||
17 | public static int AsNumber(this IntermediateFieldValue value) | ||
18 | { | ||
19 | return value?.Data == null ? 0 : (int)value.Data; | ||
20 | } | ||
21 | |||
22 | public static int? AsNullableNumber(this IntermediateFieldValue value) | ||
23 | { | ||
24 | return (int?)value?.Data; | ||
25 | } | ||
26 | |||
27 | public static IntermediateFieldPathValue AsPath(this IntermediateFieldValue value) | ||
28 | { | ||
29 | return (IntermediateFieldPathValue)value?.Data; | ||
30 | } | ||
31 | |||
32 | public static string AsString(this IntermediateFieldValue value) | ||
33 | { | ||
34 | return (string)value?.Data; | ||
35 | } | ||
36 | } | ||
37 | } | ||