Delphi 2010 DeHL Serialization XML and custom attribute : how it work?

I try to investigate DeHL with Delphi 2010 custom attribute and I get problem.

 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;

this works well : when I serialize I have this

<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

but I want this :

<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

so I want to put custom attribute in my class :

  TAppParam = class
      private
        [XmlElement('Test')] 
        FTest: TAppParamTest;
      public

        constructor Create;
        destructor Destroy; override;

        property Test: TAppParamTest read FTest write FTest;
      end;

but it does not compile :(

Where I make mistake ?

Answers


Use: [XmlName('Test')] [XmlElement]

I changed these attributes since it reduced code complexity in the serializer.


Need Your Help

How do I escape an exclamation mark in bash?

bash

Sometimes I feel the urge to put some more expressiveness in my git commit messages. Unfortunately bash does not seem to like this.