You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Spring4D
With the declaration
var FFactory : TFactory<string, TFactoryMethod<ITableQueryObject>>; type TabellNamn = class(TCustomAttribute);
I do this to register the functions that have the attribute in my factory. But the registerFactoryMethod of course need another second parameter. But I cannot find out what?
procedure TSqlFunctions.RegisterFunctions; var ctx : TRttiContext; typ : TRttiType; attr : TCustomAttribute; method : TRttiMethod; tblName : string; begin ctx := TRttiContext.Create; try typ := ctx.GetType(TSqlFunctions); for method in info.GetMethods do begin if (method.MethodKind <> mkFunction) or (method.Parent <> info) then Continue; for attr in method.GetAttributes do if attr is TabellNamn then begin tblName := AnsiUpperCase(TabellNamn(attr).GetTabellName); if not FFactory.IsRegistered(tblName) then FFactory.RegisterFactoryMethod( tblName, method); end; end; finally ctx.Free; end; end;
Stefan Glienke
unread,
Mar 19, 2025, 6:01:56 PMMar 19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Spring4D
Your declaration of FFactory should be TFactory<string, ITableQueryObject>. Then you pass a function: ITableQueryObject as second parameter.
Anders Gustavsson
unread,
Mar 20, 2025, 5:14:55 AMMar 20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Spring4D
I did some stupid trial here, but the problem is I don't know how to store
if not FFactory.IsRegistered(tblName) then begin var x := method; FFactory.RegisterFactoryMethod( tblName, function: ITableQueryObject begin Result := ITableQueryObject(x.CodeAddress); end); end;
Compiles, but of course doesn't work!
Anders Gustavsson
unread,
Mar 20, 2025, 5:15:06 AMMar 20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Spring4D
That's reasonable. But the function I should pass is identified by the "method" variable, but just putting "method" there does not work. That is where I am stuck.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Spring4D
Ah, think I got it! I am thinking "factory" but that is the wrong class in this case. A dictionary where I just store the class of the wanted object works much better (and easier!).