Delphi2CS Conversion Rules



Rules Directory

The conversion rules are defined in [Delphi2CS]\rules, the sub-directories are the UNIT name of the Delphi. You can add or modify the rules for converting the delphi objects or routines to the specified .NET class or methods.

  1. The rule for the objects:
    Please define the rules in the [Delphi2CS]\rules\[Unit-Name]\[Object-Name].xml.
  2. The rule for the routines:
    Please define the rules in the [Delphi2CS]\rules\[Unit-Name]\unit.xml.

Rules Format

The rule file includes the following targets:

- OBJECT

Define the rules for Delphi Object
Format:

<OBJECT d="" c="" >

d: the object name of the delphi
c: the full name of the .NET object to which you want to convert delphi object.
For example: Convert TForm to System.Windows.Forms.Form:
<OBJECT d="Forms.TForm" c="System.Windows.Forms.Form" >

- FIELDS

Define the rules for the fields of Delphi object
Format:
<f d="" c="" s="" />
d: the fields name of the delphi object
c: the member of the .NET obejct
s: please set the 's' to 'true' if you want to convert the delphi field to a static member of .NET object

- PROPERTIES

Define the rules for the properties of Delphi object
Format:
<p d="" c="" s="" />
d: the properties name of the delphi object
c: the member of the .NET obejct
s: Please set the 's' to 'true' if you want to convert the delphi property to a static member of .NET object

- METHODS

Define the rules for the methods of Delphi object
Format:
<m d="" c="" s="" />
d: the methods name of the delphi object
c: the member of the .NET obejct
s: please set the 's' to 'true' if you want to convert the delphi method to a static member of .NET object.

- EVENTS

Define the rules for the events of delphi object
Format:
<e d="" c="" />
d: the event name of the delphi object
c: the event name of the .NET object


- EXTENDS

The extended delphi object
Format:
<i n="" />
n: the name of the extended delphi object

How to define the rules for the routines of Delphi ?

Please define the rules in the [Unit-Name]\Unit.xml. E.g: if you want to define the rule for FileAge() routine, you can define the rule in [Delphi2CS]\rules\SysUtils\Unit.xml.


How to define the rules for Third-Party component ?

We assume your unit-name is 'myunit', your component name is 'TMycomponent', you can create a directory 'myunit' in \rules\, e.g: [Delphi2CS]\rules\myunit\, and copy the template.xml to [Delphi2CS]\rules\myunit\TMycomponent.xml , then you can define the rules in the TMycomponent.xml for converting the TMycomponent's proeprties and methods to C#.

Btw, Please put your .NET library (myunit.dll) to the folder [Delphi2CS]\bin\, otherwise Delphi2CS can not handle your rules .