From 69b15d96cebdbb7201b1849b4f62786633d70b8d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Nov 2017 10:56:09 -0700 Subject: Introduce WiX Intermediate Representation --- .../IntermediateFieldValueExtensions.cs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/WixToolset.Data/IntermediateFieldValueExtensions.cs (limited to 'src/WixToolset.Data/IntermediateFieldValueExtensions.cs') 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 @@ +// 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. + +namespace WixToolset.Data +{ + public static class IntermediateFieldValueExtensions + { + public static bool AsBool(this IntermediateFieldValue value) + { + return value?.Data == null ? false : (bool)value.Data; + } + + public static bool? AsNullableBool(this IntermediateFieldValue value) + { + return (bool?)value?.Data; + } + + public static int AsNumber(this IntermediateFieldValue value) + { + return value?.Data == null ? 0 : (int)value.Data; + } + + public static int? AsNullableNumber(this IntermediateFieldValue value) + { + return (int?)value?.Data; + } + + public static IntermediateFieldPathValue AsPath(this IntermediateFieldValue value) + { + return (IntermediateFieldPathValue)value?.Data; + } + + public static string AsString(this IntermediateFieldValue value) + { + return (string)value?.Data; + } + } +} -- cgit v1.2.3-55-g6feb