मेरे पास प्रकाशित प्रोप के साथ एक कक्षा है जिसे मैं XML में क्रमबद्ध करता हूं।विशिष्ट संपत्ति का एक अंकित मूल्य प्राप्त करें
MyAttr = class(TCustomAttribute)
private
FName: string;
public
constructor Create(const Name: string);
property Name: string read FName write FName;
end;
MyClass = class(TPersistent)
private
FClassCaption: string;
published
[MyAttr('Class')]
property ClassCaption: string read FClassCaption write FClassCaption;
end;
चूंकि XML आकार महत्वपूर्ण है, मैं विशेषताओं का उपयोग संपत्ति के लिए छोटा नाम देने के लिए (यानी मैं एक संपत्ति 'क्लास' नाम को परिभाषित नहीं कर सकते हैं)। क्रमबद्धता निम्नलिखित तरीके से लागू किया:
lPropCount := GetPropList(PTypeInfo(Obj.ClassInfo), lPropList);
for i := 0 to lPropCount - 1 do begin
lPropInfo := lPropList^[i];
lPropName := string(lPropInfo^.Name);
if IsPublishedProp(Obj, lPropName) then begin
ItemNode := RootNode.AddChild(lPropName);
ItemNode.NodeValue := VarToStr(GetPropValue(Obj, lPropName, False));
end;
end;
मैं शर्त की जरूरत है जैसे: यदि संपत्ति MyAttr के साथ चिह्नित, "MyAttr.Name" "lPropInfo^.Name" की पाने के बजाय।