Now I'm use this method to add "overload" for the standard constructor, may be it is not optimal?
procedure OnClassGenerated(Args: TClassGeneratedArgs);
var
I: Integer;
Member: TCodeTypeMember;
Proc1, Proc2: TCodeMemberConstructor;
begin
case Args.CodeType.Name of
'TAcc':
begin
for I := 0 to Args.CodeType.Members.Count - 1 do begin
Member := Args.CodeType.Members[ I ];
if Member.Name = 'Create' then begin
Proc1 := Member;
Proc1.Directives := Proc1.Directives + SetOf([mdOverload]);
Break;
end;
end;
Proc2 := TCodeMemberConstructor.Create;
Args.CodeType.Members.Add(Proc2);
Proc2.Name := 'Create';
Proc2.Directives := SetOf([mdOverload]);
Proc2.Visibility := mvPublic;
Proc2.AddParameter('Name', 'string').Modifier := pmConst;
Proc2.AddSnippet('Create;');
Proc2.AddSnippet('Self.Name := Name;');
end;
end;
end;