Jump to content
wuwuxin

Possible to "extend" or "inherit" an existing class/record helper?

Recommended Posts

For System.SysUtils.TStringHelper,  I have to need to add some additional methods -  is it possible to extend or "inherit" an existing class/record helper to add user-specified methods?

Share this post


Link to post
17 minutes ago, wuwuxin said:

is it possible to extend or "inherit" an existing class/record helper to add user-specified methods?

No. Longstanding limitation. Kinda sucks. Can't have multiple helpers which would be another way to do what you want. 

Edited by David Heffernan
  • Thanks 1

Share this post


Link to post

While the above is valid for record helpers, it is indeed possible to extend class helpers. (It es even documented: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Class_and_Record_Helpers_(Delphi)#Helper_Syntax)

 

In this example we extend the existing class helper TRESTRequestParameterHelper from REST.Client.pas (Delphi 11) with another method without hiding the ContentType member of TRESTRequestParameterHelper.

 

type
  TMyRESTRequestParameterHelper = class helper (TRESTRequestParameterHelper)  for TRESTRequestParameter
    procedure MyTest;
  end;

 

  • Like 4

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×