Skip to content

Commit 6320847

Browse files
committed
Backward compatibility to the Notification library
Former-commit-id: 91a6cbdadd70c8d39d5f89b2d9ceeffd432bde56 [formerly a73dffcf7142ce09aee184ea554ffd6a0b4ad663] [formerly 9fe1c0aae4abdef8b0277a4f59b34b6dfc1b76dd [formerly 437a152e94a7edb1b8410b00a0706d5c3c0fcdb8]] [formerly 145f8442a8a9762332d33f1af814fb83355c0bb1 [formerly f442071856bfe2e7968111bb8d9e5246af984efd] [formerly 89ce001b13bf88542329189d624cd1ca16ad1c16 [formerly d524a51ce00cf263e5633a243be39e088ab6b09f]]] Former-commit-id: 76a3353d7db49e7035d2b8245e2f1f9b6c2f7aca [formerly 0731eb5668ba3cbf6b7016ad2f7398869608a91c] [formerly d8497a171e3760e4ff1f8f3ef7f8ea339974130b [formerly 612feb4d8fc1660aa90701723ff860a8571c7ba4]] Former-commit-id: 10a7b3dd55d5276ee18ecd98db2fe12eb4779e26 [formerly 85ed553e2a3f17bf17a4ceec3d4025d2f02dd1c3] Former-commit-id: 2ed3eea142e8ddebea444fd9c7d64405424f444c Former-commit-id: b6e1b5b
1 parent 7fa1c7f commit 6320847

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/Tools/Notification/PyTools.Notification.Channel.pas

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,32 @@ implementation
207207
System.Rtti,
208208
PyTools.Exception;
209209

210+
type
211+
//For backward compatibility
212+
TRttiObjectHelper = class helper for TRttiObject
213+
public
214+
function GetAttribute(AAttrClass: TCustomAttributeClass): TCustomAttribute; overload;
215+
function GetAttribute<T: TCustomAttribute>: T; overload; inline;
216+
end;
217+
218+
{ TRttiObjectHelper }
219+
220+
function TRttiObjectHelper.GetAttribute(
221+
AAttrClass: TCustomAttributeClass): TCustomAttribute;
222+
var
223+
LAttr: TCustomAttribute;
224+
begin
225+
for LAttr in GetAttributes do
226+
if LAttr is AAttrClass then
227+
Exit(LAttr);
228+
Result := nil;
229+
end;
230+
231+
function TRttiObjectHelper.GetAttribute<T>: T;
232+
begin
233+
Result := T(GetAttribute(T));
234+
end;
235+
210236
{ RequestChannelAttribute }
211237

212238
constructor RequestChannelAttribute.Create(const AIdentifier: TRequestChannelIdentifier);

0 commit comments

Comments
 (0)