You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
929 B

  1. unit uutlAlgorithm;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils;
  6. function Supports(const aInstance: TObject; const aClass: TClass; out aObj): Boolean; overload;
  7. implementation
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  10. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  11. function Supports(const aInstance: TObject; const aClass: TClass; out aObj): Boolean;
  12. begin
  13. result := Assigned(aInstance) and aInstance.InheritsFrom(aClass);
  14. if result then
  15. TObject(aObj) := aInstance
  16. else
  17. TObject(aObj) := nil;
  18. end;
  19. end.