AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Anonyme Methoden in Attributen

Ein Thema von Neutral General · begonnen am 11. Feb 2015 · letzter Beitrag vom 11. Feb 2015
 
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

Anonyme Methoden in Attributen

  Alt 11. Feb 2015, 14:05
Delphi-Version: XE7
Hallo,

Das scheint leider nicht zu gehen:
Delphi-Quellcode:
TAnonym = reference to procedure;

TMyCustomAttribute = class(TCustomAttribute)
  constructor Create(Anonym: TAnonym); // compiliert
end;

// Funktioniert nicht: "Konstantenausdruck erwartet"
[TMyCustomAttribute(
  procedure
  begin
    ShowMessage('Test');
  end)
]
TTestclass = class

end;
Das finde ich schade und ich wäre froh wenn Embarcadero sowas implementieren könnte.
Denn ich finde dass der Ausdruck konstant genug ist.

Ansonsten: Kennt jemand eine Alternative?
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz