Automating the Creation of Properties with the Class Explorer
Go Up to Object Pascal Class Explorer Topics
Using the Object Pascal Class Explorer you can automate the creation of properties.
You can use the Add Property dialog box to add to a class the code for the declaration of a property and for the default implementations of the getter and setter methods.
To automate the creation of properties:
- Open the Object Pascal Class Explorer window by choosing View > Class Explorer .
- In the Class Viewer pane, right-click a class into which you wish to add a property.
- On the context menu, choose the Add Property item. The Add Property dialog box appears.
- Into Property name type the name for the property to be added. This name will be used to generate the default names to the getter, setter, and field.
- In the Add to class combo box, select the class into which you wish to add the property. By default, the class currently selected in the Class Viewer pane is prompted. You can, however, change this to any other available class selecting it from the drop-down list in the combo box.
- In the Type combo box, select the type of the property value. You can select one of the predefined types from the drop-down list in the combo box or you can type in any other existing type.
- In the Visibility group select one of the visibility specifiers. The selected visibility specifier will be applied to the property being created.
- In the Reader and Writer combo boxes, specify the field or methods that will be used to read and write the property value.The default names based on the specified property name are prompted. You can, however, change these names to any other available methods selecting them from the drop-down list in the combo box or type them explicitly.
Warning: Be careful selecting existing methods in the Reader and Writer combo boxes. If the selected methods already have implementations, then the code of these implementations can be silently deleted!
- Check ON the Create field check box to create a field that will store the property value.
- Click OK. The code for the property declaration and the default implementations of the specified getter and setter methods are inserted into the specified class.