Better collection support
Support for optional attributes
This commit is contained in:
parent
de277ebcfc
commit
56013f783a
Binary file not shown.
@ -289,6 +289,13 @@ var
|
|||||||
begin
|
begin
|
||||||
case AProperty.PropertyType of
|
case AProperty.PropertyType of
|
||||||
ptSimple:
|
ptSimple:
|
||||||
|
if Assigned(AProperty.Collection) then
|
||||||
|
begin
|
||||||
|
if AInterfaceName then
|
||||||
|
Result := ItemInterface
|
||||||
|
else
|
||||||
|
Result := ItemClass;
|
||||||
|
end else
|
||||||
Result := TranslateDataType(TXMLDataBindingSimpleProperty(AProperty).DataType);
|
Result := TranslateDataType(TXMLDataBindingSimpleProperty(AProperty).DataType);
|
||||||
ptItem:
|
ptItem:
|
||||||
begin
|
begin
|
||||||
@ -785,10 +792,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
propertyItem := AItem.Properties[propertyIndex];
|
propertyItem := AItem.Properties[propertyIndex];
|
||||||
|
|
||||||
if propertyItem.PropertyType = ptItem then
|
|
||||||
begin
|
|
||||||
itemProperty := TXMLDataBindingItemProperty(propertyItem);
|
|
||||||
|
|
||||||
if (not AItem.IsCollection) and Assigned(propertyItem.Collection) then
|
if (not AItem.IsCollection) and Assigned(propertyItem.Collection) then
|
||||||
begin
|
begin
|
||||||
WritePrototype;
|
WritePrototype;
|
||||||
@ -796,19 +799,26 @@ begin
|
|||||||
{ Inline collection }
|
{ Inline collection }
|
||||||
if ASection = dxsImplementation then
|
if ASection = dxsImplementation then
|
||||||
begin
|
begin
|
||||||
|
if propertyItem.PropertyType = ptItem then
|
||||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<ItemSourceName>:s'', %<ItemClass>:s);',
|
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<ItemSourceName>:s'', %<ItemClass>:s);',
|
||||||
['ItemSourceName', propertyItem.Name,
|
['ItemSourceName', propertyItem.Name,
|
||||||
'ItemClass', PrefixClass + itemProperty.Item.TranslatedName]);
|
'ItemClass', GetDataTypeName(propertyItem, False)]);
|
||||||
|
|
||||||
AStream.WriteLnNamedFmt(' %<FieldName>:s := CreateCollection(%<CollectionClass>:s, %<ItemInterface>:s, ''%<ItemSourceName>:s'') as %<CollectionInterface>:s;',
|
AStream.WriteLnNamedFmt(' %<FieldName>:s := CreateCollection(%<CollectionClass>:s, %<ItemInterface>:s, ''%<ItemSourceName>:s'') as %<CollectionInterface>:s;',
|
||||||
['FieldName', PrefixField + propertyItem.TranslatedName,
|
['FieldName', PrefixField + propertyItem.TranslatedName,
|
||||||
'CollectionClass', PrefixClass + propertyItem.Collection.TranslatedName,
|
'CollectionClass', PrefixClass + propertyItem.Collection.TranslatedName,
|
||||||
'CollectionInterface', PrefixInterface + propertyItem.Collection.TranslatedName,
|
'CollectionInterface', PrefixInterface + propertyItem.Collection.TranslatedName,
|
||||||
'ItemInterface', PrefixInterface + itemProperty.Item.TranslatedName,
|
'ItemInterface', GetDataTypeName(propertyItem, True),
|
||||||
'ItemSourceName', propertyItem.Name]);
|
'ItemSourceName', propertyItem.Name]);
|
||||||
end;
|
end;
|
||||||
end else if ((not AItem.IsCollection) or
|
end;
|
||||||
(propertyItem <> AItem.CollectionItem)) then
|
|
||||||
|
if propertyItem.PropertyType = ptItem then
|
||||||
|
begin
|
||||||
|
itemProperty := TXMLDataBindingItemProperty(propertyItem);
|
||||||
|
|
||||||
|
if (not AItem.IsCollection) or
|
||||||
|
(propertyItem <> AItem.CollectionItem) then
|
||||||
begin
|
begin
|
||||||
{ Item property }
|
{ Item property }
|
||||||
if Assigned(itemProperty.Item) and
|
if Assigned(itemProperty.Item) and
|
||||||
@ -945,8 +955,8 @@ begin
|
|||||||
ptSimple:
|
ptSimple:
|
||||||
begin
|
begin
|
||||||
dataTypeName := TranslateDataType(TXMLDataBindingSimpleProperty(AItem.CollectionItem).DataType);
|
dataTypeName := TranslateDataType(TXMLDataBindingSimpleProperty(AItem.CollectionItem).DataType);
|
||||||
dataClassName := 'TXMLNode';
|
dataClassName := ItemClass;
|
||||||
dataIntfName := 'IXMLNode';
|
dataIntfName := ItemInterface;
|
||||||
end;
|
end;
|
||||||
ptItem:
|
ptItem:
|
||||||
begin
|
begin
|
||||||
@ -1215,8 +1225,10 @@ begin
|
|||||||
begin
|
begin
|
||||||
WriteNewLine;
|
WriteNewLine;
|
||||||
|
|
||||||
// #ToDo1 (MvR) 21-4-2008: optional attributes!
|
|
||||||
if writeOptional then
|
if writeOptional then
|
||||||
|
if AProperty.IsAttribute then
|
||||||
|
sourceCode.Add(PropertyImplMethodGetOptionalAttr)
|
||||||
|
else
|
||||||
sourceCode.Add(PropertyImplMethodGetOptional);
|
sourceCode.Add(PropertyImplMethodGetOptional);
|
||||||
|
|
||||||
if writeNil then
|
if writeNil then
|
||||||
@ -1229,6 +1241,12 @@ begin
|
|||||||
|
|
||||||
case AProperty.PropertyType of
|
case AProperty.PropertyType of
|
||||||
ptSimple:
|
ptSimple:
|
||||||
|
if Assigned(AProperty.Collection) then
|
||||||
|
begin
|
||||||
|
sourceCode.Add('begin');
|
||||||
|
sourceCode.Add(' Result := %<FieldName>:s;');
|
||||||
|
sourceCode.Add('end;');
|
||||||
|
end else
|
||||||
sourceCode.Add(XMLToNativeDataType('Result',
|
sourceCode.Add(XMLToNativeDataType('Result',
|
||||||
'%<PropertySourceName>:s',
|
'%<PropertySourceName>:s',
|
||||||
TXMLDataBindingSimpleProperty(AProperty).DataType,
|
TXMLDataBindingSimpleProperty(AProperty).DataType,
|
||||||
|
@ -92,11 +92,18 @@ const
|
|||||||
'end;' + CrLf +
|
'end;' + CrLf +
|
||||||
'' + CrLf;
|
'' + CrLf;
|
||||||
|
|
||||||
|
PropertyImplMethodGetOptionalAttr = 'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
|
||||||
|
'begin' + CrLf +
|
||||||
|
' Result := Assigned(AttributeNodes.FindNode(''%<PropertySourceName>:s''));' + CrLf +
|
||||||
|
'end;' + CrLf +
|
||||||
|
'' + CrLf;
|
||||||
|
|
||||||
PropertyImplMethodGetNil = 'function TXML%<Name>:s.Get%<PropertyName>:sIsNil: Boolean;' + CrLf +
|
PropertyImplMethodGetNil = 'function TXML%<Name>:s.Get%<PropertyName>:sIsNil: Boolean;' + CrLf +
|
||||||
'begin' + CrLf +
|
'begin' + CrLf +
|
||||||
' Result := GetNodeIsNil(ChildNodes[''%<PropertySourceName>:s'']);' + CrLf +
|
' Result := GetNodeIsNil(ChildNodes[''%<PropertySourceName>:s'']);' + CrLf +
|
||||||
'end;' + CrLf +
|
'end;' + CrLf +
|
||||||
'' + CrLf;
|
'' + CrLf;
|
||||||
|
|
||||||
PropertyImplMethodSetNil = 'procedure TXML%<Name>:s.Set%<PropertyName>:sIsNil(const Value: Boolean);' + CrLf +
|
PropertyImplMethodSetNil = 'procedure TXML%<Name>:s.Set%<PropertyName>:sIsNil(const Value: Boolean);' + CrLf +
|
||||||
'begin' + CrLf +
|
'begin' + CrLf +
|
||||||
' SetNodeIsNil(ChildNodes[''%<PropertySourceName>:s''], Value);' + CrLf +
|
' SetNodeIsNil(ChildNodes[''%<PropertySourceName>:s''], Value);' + CrLf +
|
||||||
|
Loading…
Reference in New Issue
Block a user