I have a multiple classes TDecimal3, TDecimal5, as below etc. I want to create a generic helper class that will return 3 for TDecimal3 and 5 for TDecimal5. Is this possible?
type
TDecimal3 = string[3];
TDecimal5 = string[5];
TDecimal3Helper = record helper for TDecimal3
procedure GetSizeandPrecision( var piSize : Integer; var piPrecision : Integer );
end;
{ TDecimal3Helper }
procedure TDecimal3Helper.GetSizeandPrecision(var piSize, piPrecision: Integer);
var
lsString : String;
LContext: TRttiContext;
LType: TRttiType;
begin
LContext := TRttiContext.Create;
LType := LContext.GetType(TypeInfo(Self));
ShowMessage(LType.Name);
LContext.Free;
end;
{ TfrmTestHelperClass }
procedure TfrmTestHelperClass.btnTestDecimalClick(Sender: TObject);
begin
TestDecimalInfo;
end;
procedure TfrmTestHelperClass.TestDecimalInfo;
var
ldec : TDecimal3;
i,j : Integer;
begin
ldec.GetSizeandPrecision(i,j);
end;