From cf6531a216dc248177116399120f02d67731f312 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 18 Oct 2019 11:28:14 -0700 Subject: Small fixes to tuples --- src/WixToolset.Data/IntermediateTupleExtensions.cs | 25 +++--------- src/WixToolset.Data/Tuples/ClassTuple.cs | 4 +- src/WixToolset.Data/Tuples/TextStyleTuple.cs | 44 +++++++++++++--------- 3 files changed, 33 insertions(+), 40 deletions(-) diff --git a/src/WixToolset.Data/IntermediateTupleExtensions.cs b/src/WixToolset.Data/IntermediateTupleExtensions.cs index dd488dc5..7fb2a6c3 100644 --- a/src/WixToolset.Data/IntermediateTupleExtensions.cs +++ b/src/WixToolset.Data/IntermediateTupleExtensions.cs @@ -16,11 +16,6 @@ namespace WixToolset.Data public static IntermediateField Set(this IntermediateTuple tuple, int index, bool value) { - if (value == default && NoFieldMetadata(tuple, index)) - { - return tuple.Fields[index] = null; - } - var definition = tuple.Definition.FieldDefinitions[index]; var field = tuple.Fields[index].Set(definition, value); @@ -30,7 +25,7 @@ namespace WixToolset.Data public static IntermediateField Set(this IntermediateTuple tuple, int index, bool? value) { - if (value == default && NoFieldMetadata(tuple, index)) + if (value == null && NoFieldMetadata(tuple, index)) { return tuple.Fields[index] = null; } @@ -44,11 +39,6 @@ namespace WixToolset.Data public static IntermediateField Set(this IntermediateTuple tuple, int index, long value) { - if (value == default && NoFieldMetadata(tuple, index)) - { - return tuple.Fields[index] = null; - } - var definition = tuple.Definition.FieldDefinitions[index]; var field = tuple.Fields[index].Set(definition, value); @@ -58,7 +48,7 @@ namespace WixToolset.Data public static IntermediateField Set(this IntermediateTuple tuple, int index, long? value) { - if (value == default && NoFieldMetadata(tuple, index)) + if (value == null && NoFieldMetadata(tuple, index)) { return tuple.Fields[index] = null; } @@ -72,11 +62,6 @@ namespace WixToolset.Data public static IntermediateField Set(this IntermediateTuple tuple, int index, int value) { - if (value == default && NoFieldMetadata(tuple, index)) - { - return tuple.Fields[index] = null; - } - var definition = tuple.Definition.FieldDefinitions[index]; var field = tuple.Fields[index].Set(definition, value); @@ -86,7 +71,7 @@ namespace WixToolset.Data public static IntermediateField Set(this IntermediateTuple tuple, int index, int? value) { - if (value == default && NoFieldMetadata(tuple, index)) + if (value == null && NoFieldMetadata(tuple, index)) { return tuple.Fields[index] = null; } @@ -100,7 +85,7 @@ namespace WixToolset.Data public static IntermediateField Set(this IntermediateTuple tuple, int index, IntermediateFieldPathValue value) { - if (value == default && NoFieldMetadata(tuple, index)) + if (value == null && NoFieldMetadata(tuple, index)) { return tuple.Fields[index] = null; } @@ -114,7 +99,7 @@ namespace WixToolset.Data public static IntermediateField Set(this IntermediateTuple tuple, int index, string value) { - if (value == default && NoFieldMetadata(tuple, index)) + if (value == null && NoFieldMetadata(tuple, index)) { return tuple.Fields[index] = null; } diff --git a/src/WixToolset.Data/Tuples/ClassTuple.cs b/src/WixToolset.Data/Tuples/ClassTuple.cs index 5e40fe35..a5ff89e8 100644 --- a/src/WixToolset.Data/Tuples/ClassTuple.cs +++ b/src/WixToolset.Data/Tuples/ClassTuple.cs @@ -107,9 +107,9 @@ namespace WixToolset.Data.Tuples set => this.Set((int)ClassTupleFields.IconRef, value); } - public int IconIndex + public int? IconIndex { - get => (int)this.Fields[(int)ClassTupleFields.IconIndex]; + get => (int?)this.Fields[(int)ClassTupleFields.IconIndex]; set => this.Set((int)ClassTupleFields.IconIndex, value); } diff --git a/src/WixToolset.Data/Tuples/TextStyleTuple.cs b/src/WixToolset.Data/Tuples/TextStyleTuple.cs index e4929ccf..3614808e 100644 --- a/src/WixToolset.Data/Tuples/TextStyleTuple.cs +++ b/src/WixToolset.Data/Tuples/TextStyleTuple.cs @@ -10,10 +10,11 @@ namespace WixToolset.Data TupleDefinitionType.TextStyle, new[] { - new IntermediateFieldDefinition(nameof(TextStyleTupleFields.TextStyle), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(TextStyleTupleFields.FaceName), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(TextStyleTupleFields.Size), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(TextStyleTupleFields.Color), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(TextStyleTupleFields.Red), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(TextStyleTupleFields.Green), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(TextStyleTupleFields.Blue), IntermediateFieldType.Number), new IntermediateFieldDefinition(nameof(TextStyleTupleFields.Bold), IntermediateFieldType.Bool), new IntermediateFieldDefinition(nameof(TextStyleTupleFields.Italic), IntermediateFieldType.Bool), new IntermediateFieldDefinition(nameof(TextStyleTupleFields.Strike), IntermediateFieldType.Bool), @@ -27,10 +28,11 @@ namespace WixToolset.Data.Tuples { public enum TextStyleTupleFields { - TextStyle, FaceName, Size, - Color, + Red, + Green, + Blue, Bold, Italic, Strike, @@ -49,12 +51,6 @@ namespace WixToolset.Data.Tuples public IntermediateField this[TextStyleTupleFields index] => this.Fields[(int)index]; - public string TextStyle - { - get => (string)this.Fields[(int)TextStyleTupleFields.TextStyle]; - set => this.Set((int)TextStyleTupleFields.TextStyle, value); - } - public string FaceName { get => (string)this.Fields[(int)TextStyleTupleFields.FaceName]; @@ -63,37 +59,49 @@ namespace WixToolset.Data.Tuples public int Size { - get => this.Fields[(int)TextStyleTupleFields.Size].AsNumber(); + get => (int)this.Fields[(int)TextStyleTupleFields.Size]; set => this.Set((int)TextStyleTupleFields.Size, value); } - public int Color + public int? Red + { + get => (int?)this.Fields[(int)TextStyleTupleFields.Red]; + set => this.Set((int)TextStyleTupleFields.Red, value); + } + + public int? Green + { + get => (int?)this.Fields[(int)TextStyleTupleFields.Green]; + set => this.Set((int)TextStyleTupleFields.Green, value); + } + + public int? Blue { - get => (int)this.Fields[(int)TextStyleTupleFields.Color].AsNumber(); - set => this.Set((int)TextStyleTupleFields.Color, value); + get => (int?)this.Fields[(int)TextStyleTupleFields.Blue]; + set => this.Set((int)TextStyleTupleFields.Blue, value); } public bool Bold { - get => this.Fields[(int)TextStyleTupleFields.Bold].AsBool(); + get => (bool)this.Fields[(int)TextStyleTupleFields.Bold]; set => this.Set((int)TextStyleTupleFields.Bold, value); } public bool Italic { - get => this.Fields[(int)TextStyleTupleFields.Italic].AsBool(); + get => (bool)this.Fields[(int)TextStyleTupleFields.Italic]; set => this.Set((int)TextStyleTupleFields.Italic, value); } public bool Strike { - get => this.Fields[(int)TextStyleTupleFields.Strike].AsBool(); + get => (bool)this.Fields[(int)TextStyleTupleFields.Strike]; set => this.Set((int)TextStyleTupleFields.Strike, value); } public bool Underline { - get => this.Fields[(int)TextStyleTupleFields.Underline].AsBool(); + get => (bool)this.Fields[(int)TextStyleTupleFields.Underline]; set => this.Set((int)TextStyleTupleFields.Underline, value); } } -- cgit v1.2.3-55-g6feb