我想完全禁用/删除这个警告,因为我的包是一个完整的RAD服务器模块,所以这些线程变量永远不会有机会在包外使用。
我在threadvar定义上尝试了{$WARNINGS OFF},但它没有删除警告。
unit CustomSession;
interface
uses
System.Classes,
System.SysUtils,
EMS.ResourceAPI;
type
TKpSession = record
UserId: string;
UserName: string;
SessionToken: string;
class procedure ValidateRequest(const AContext: TEndpointContext); static;
end;
{$WARNINGS OFF}
threadvar
KpSession: TKpSession;
{$WARNINGS ON}
resourcestring
rsNotLoggedIn = 'You need to be logged in to access %s - %s';
implementation
uses
CustomLocalize;
class procedure TKpSession.ValidateRequest(const AContext: TEndpointContext);
var
UserId, Resource, Endpoint: string;
begin
Resource := AContext.Request.Resource;
Endpoint := AContext.EndpointName;
if Assigned(AContext.User) then
UserId := AContext.User.UserName;
if UserId.Trim <> '' then
begin
KpSession.UserId := UserId;
KpSession.UserName := UserId; // Retrieve username from the DDBB ?
KpSession.SessionToken := AContext.User.SessionToken;
// to-do: Check Permissions for the User on this Request/Endpoint.
end
else
begin
raise Exception.CreateFmt(_(rsNotLoggedIn), [Resource, Endpoint]);
end;
end;
end.
字符串
1条答案
按热度按时间lsmd5eda1#
你可以把这条线放在这个单元的顶部:
字符串