From 3c9f47f80ed9b968a55f824b30742ad9bdb020e7 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Fri, 21 Jul 2017 09:47:14 +0200 Subject: [PATCH] Empty check only simple types --- Units/DelphiXMLDataBindingGenerator.pas | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Units/DelphiXMLDataBindingGenerator.pas b/Units/DelphiXMLDataBindingGenerator.pas index 70aedb9..974f9ad 100644 --- a/Units/DelphiXMLDataBindingGenerator.pas +++ b/Units/DelphiXMLDataBindingGenerator.pas @@ -1144,7 +1144,6 @@ var writeStream: Boolean; typeMapping: TTypeMapping; nodeType: TDelphiNodeType; - elementType: TDelphiElementType; begin Result := False; @@ -1298,13 +1297,21 @@ begin WriteNewLine; if writeOptional then - if AProperty.IsAttribute then - sourceCode.Add(IfThen(HasChecksEmpty, PropertyImplMethodGetOptionalAttrEmpty, PropertyImplMethodGetOptionalAttr)) - else + begin + if HasChecksEmpty and (AProperty.PropertyType = ptSimple) and (not Assigned(AProperty.Collection)) then begin - elementType := GetDelphiElementType(nodeType); - sourceCode.Add(IfThen(HasChecksEmpty, PropertyImplMethodGetOptionalEmpty[elementType], PropertyImplMethodGetOptional[elementType])); + if AProperty.IsAttribute then + sourceCode.Add(PropertyImplMethodGetOptionalAttrEmpty) + else + sourceCode.Add(PropertyImplMethodGetOptionalEmpty[GetDelphiElementType(nodeType)]); + end else + begin + if AProperty.IsAttribute then + sourceCode.Add(PropertyImplMethodGetOptionalAttr) + else + sourceCode.Add(PropertyImplMethodGetOptional[GetDelphiElementType(nodeType)]); end; + end; if writeNil then sourceCode.Add(PropertyImplMethodGetNil[GetDelphiElementType(nodeType)]);