我尝试使用 Delphi 2010 自定义属性调查DeHL ,但我遇到了问题。
TAppParamTest = class
public
User: string;
Password: string;
end;
TAppParam = class
private
FTest: TAppParamTest;
public
constructor Create;
destructor Destroy; override;
property Test: TAppParamTest read FTest write FTest;
end;
这很好用:当我序列化时,我有这个
<TAppParam xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:DeHL="http://alex.ciobanu.org/DeHL.Serialization.XML" DeHL:class="AppParam_unt.TAppParam" DeHL:refid="1">
<FTest DeHL:class="AppParam_unt.TAppParamTest" DeHL:refid="2">
<User>User</User>
<Password>Psw</Password>
</FTest>
</TAppParam
但我想要这个:
<TAppParam xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:DeHL="http://alex.ciobanu.org/DeHL.Serialization.XML" DeHL:class="AppParam_unt.TAppParam" DeHL:refid="1">
<Test DeHL:class="AppParam_unt.TAppParamTest" DeHL:refid="2">
<User>User</User>
<Password>Psw</Password>
</Test>
</TAppParam
所以我想将自定义属性放在我的班级中:
TAppParam = class
private
[XmlElement('Test')]
FTest: TAppParamTest;
public
constructor Create;
destructor Destroy; override;
property Test: TAppParamTest read FTest write FTest;
end;
但它不编译:(
我在哪里犯错?