From 3761d820d9407c0417e7ef26386d9d906e1e5329 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 2 Aug 2020 08:26:41 -0600 Subject: Add enum for bundle variable Type. --- src/WixToolset.Data/Symbols/WixBundleVariableSymbol.cs | 17 ++++++++++++++--- src/WixToolset.Data/Symbols/WixSetVariableSymbol.cs | 8 +++++--- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Data/Symbols/WixBundleVariableSymbol.cs b/src/WixToolset.Data/Symbols/WixBundleVariableSymbol.cs index 85cf2798..d68ac682 100644 --- a/src/WixToolset.Data/Symbols/WixBundleVariableSymbol.cs +++ b/src/WixToolset.Data/Symbols/WixBundleVariableSymbol.cs @@ -21,6 +21,8 @@ namespace WixToolset.Data namespace WixToolset.Data.Symbols { + using System; + public enum WixBundleVariableSymbolFields { Value, @@ -29,6 +31,15 @@ namespace WixToolset.Data.Symbols Persisted, } + public enum WixBundleVariableType + { + Unknown, + Formatted, + Numeric, + String, + Version, + } + public class WixBundleVariableSymbol : IntermediateSymbol { public WixBundleVariableSymbol() : base(SymbolDefinitions.WixBundleVariable, null, null) @@ -47,10 +58,10 @@ namespace WixToolset.Data.Symbols set => this.Set((int)WixBundleVariableSymbolFields.Value, value); } - public string Type + public WixBundleVariableType Type { - get => (string)this.Fields[(int)WixBundleVariableSymbolFields.Type]; - set => this.Set((int)WixBundleVariableSymbolFields.Type, value); + get => Enum.TryParse((string)this.Fields[(int)WixBundleVariableSymbolFields.Type], true, out WixBundleVariableType value) ? value : WixBundleVariableType.Unknown; + set => this.Set((int)WixBundleVariableSymbolFields.Type, value.ToString().ToLowerInvariant()); } public bool Hidden diff --git a/src/WixToolset.Data/Symbols/WixSetVariableSymbol.cs b/src/WixToolset.Data/Symbols/WixSetVariableSymbol.cs index 503c328b..05fdf561 100644 --- a/src/WixToolset.Data/Symbols/WixSetVariableSymbol.cs +++ b/src/WixToolset.Data/Symbols/WixSetVariableSymbol.cs @@ -19,6 +19,8 @@ namespace WixToolset.Data namespace WixToolset.Data.Symbols { + using System; + public enum WixSetVariableSymbolFields { Value, @@ -43,10 +45,10 @@ namespace WixToolset.Data.Symbols set => this.Set((int)WixSetVariableSymbolFields.Value, value); } - public string Type + public WixBundleVariableType Type { - get => (string)this.Fields[(int)WixSetVariableSymbolFields.Type]; - set => this.Set((int)WixSetVariableSymbolFields.Type, value); + get => Enum.TryParse((string)this.Fields[(int)WixSetVariableSymbolFields.Type], true, out WixBundleVariableType value) ? value : WixBundleVariableType.Unknown; + set => this.Set((int)WixSetVariableSymbolFields.Type, value.ToString().ToLowerInvariant()); } } } -- cgit v1.2.3-55-g6feb