Skip to content

Commit 89e5d54

Browse files
committed
Backward compatibility to the Notification library
1 parent 584e050 commit 89e5d54

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

+26
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)