Support of 'Def' getter method for optional elements
This commit is contained in:
parent
3c9f47f80e
commit
5451a52cd2
@ -1223,7 +1223,11 @@ begin
|
||||
WriteNewLine;
|
||||
|
||||
if writeOptional then
|
||||
begin
|
||||
sourceCode.Add(PropertyIntfMethodGetOptional);
|
||||
if AProperty.PropertyType = ptSimple then
|
||||
sourceCode.Add(PropertyIntfMethodGetOptionalOrDefault);
|
||||
end;
|
||||
|
||||
if writeNil then
|
||||
sourceCode.Add(PropertyIntfMethodGetNil);
|
||||
@ -1311,6 +1315,9 @@ begin
|
||||
else
|
||||
sourceCode.Add(PropertyImplMethodGetOptional[GetDelphiElementType(nodeType)]);
|
||||
end;
|
||||
|
||||
if AProperty.PropertyType = ptSimple then
|
||||
sourceCode.Add(PropertyImplMethodGetOptionalOrDefault);
|
||||
end;
|
||||
|
||||
if writeNil then
|
||||
|
@ -156,6 +156,7 @@ const
|
||||
'end;' + CrLf;
|
||||
|
||||
PropertyIntfMethodGetOptional = ' function GetHas%<PropertyName>:s: Boolean;';
|
||||
PropertyIntfMethodGetOptionalOrDefault = ' function %<PropertyName>:sDef(const ADefaultValue: %<DataType>:s = Default(%<DataType>:s)): %<DataType>:s;';
|
||||
PropertyIntfMethodGetNil = ' function Get%<PropertyName>:sIsNil: Boolean;';
|
||||
PropertyIntfMethodGetText = ' function Get%<PropertyName>:sText: WideString;';
|
||||
PropertyIntfMethodGet = ' function Get%<PropertyName>:s: %<DataType>:s;';
|
||||
@ -175,6 +176,16 @@ const
|
||||
PropertyInterfaceText = ' property %<PropertyName>:sText: WideString read Get%<PropertyName>:sText write Set%<PropertyName>:sText;';
|
||||
PropertyInterface = ' property %<PropertyName>:s: %<DataType>:s read Get%<PropertyName>:s write Set%<PropertyName>:s;';
|
||||
|
||||
|
||||
PropertyImplMethodGetOptionalOrDefault = 'function TXML%<Name>:s.%<PropertyName>:sDef(const ADefaultValue: %<DataType>:s): %<DataType>:s;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' if GetHas%<PropertySourceName>:s then' + CrLf +
|
||||
' Result := Get%<PropertySourceName>:s' + CrLf +
|
||||
' else' + CrLf +
|
||||
' Result := ADefaultValue;' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf;
|
||||
|
||||
PropertyImplMethodGetOptional: array[TDelphiElementType] of string =
|
||||
(
|
||||
{ dntElement }
|
||||
|
Loading…
Reference in New Issue
Block a user