Delphi 2010 RTTI:探索枚举 [英] Delphi 2010 RTTI : Explore Enumerations

查看:139
本文介绍了Delphi 2010 RTTI:探索枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到这样的枚举:

 键入
TTypeOfData =(
[XmlName('ABC' )] todABC,
[XmlName('DEF')] todDEF,
[XmlName('GHI')] todGHI
);

其中XmlName是用于定义此枚举成员的序列化字符串的自定义属性。 >

如何查看附加到此枚举的每个成员的属性?

解决方案

与枚举中的元素相关联的属性当前不存储在可执行文件中的Win32 RTTI数据中。 RTTI已经对可执行文件的大小进行了公正的增加,所以必须在某个地方绘制一些线条。在Delphi Win32中的属性支持类型,记录字段和字段,方法,参数和类的属性。



属性声明不会导致错误因为与Delphi for .NET的向后兼容。


Considering such an enumeration :

type
  TTypeOfData = (
    [XmlName('ABC')] todABC,
    [XmlName('DEF')] todDEF,  
    [XmlName('GHI')] todGHI
  );

Where XmlName is a custom attribute used to define the serialization string for members of this enumeration.

How can I explore the attributes attached to each member of this enumeration ?

解决方案

Attributes associated with elements in enumerations are not currently stored in Win32 RTTI data in the executable. RTTI is already responsible for a fair increase in the size of executables, so some lines had to be drawn somewhere. Attributes in Delphi Win32 are supported on types, on fields of records, and fields, methods, their parameters, and properties of classes.

The attribute declarations don't cause errors because of backward compatibility with Delphi for .NET.

这篇关于Delphi 2010 RTTI:探索枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆