德尔福新型RTTI的实用性 - 属性,价值观 [英] Practical usage for Delphi's new RTTI - Attributes,Values

查看:148
本文介绍了德尔福新型RTTI的实用性 - 属性,价值观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现一个关于Delphi中新的RTTI的很好的解释,但是我不明白我读过的一个重要的事情 - 我可以在哪里使用?

I found a great explanation about the new RTTI in Delphi,but I don't understand one important thing about all I have read - Where can I use that?

它应该替换什么?

推荐答案

扩展RTTI的工作原理就像Reflection in .NET。它可以访问您的内部应用程序结构信息。您可以访问类属性,方法等。在运行时,您以前无法执行的范围。

The extended RTTI works like Reflection in .NET. It gives you access to your internal application structure information. You can access class properties, methods etc.. at runtime, at extent you could not do it before.

使用它的一些方法:


  1. 类到XML的序列化/反序列化或其他媒体

  2. 将对象映射到数据库。 ORM。

  3. 克隆对象

  4. 动态调用方法

  5. 在运行时对象进行扫描

  6. 更容易开发插件类型的系统

  1. Serialization / Deserialization of classes to XML or other media
  2. Mapping of objects to databases. ORM.
  3. Cloning of objects
  4. Dynamic invocation of methods
  5. "Scanning" of object at runtime and acting according to that.
  6. Easier development of "plugin" type systems

可能很多情况下使用它将是有益的。简而言之,它为您的应用程序添加动态方面。您的产品能够在运行时做一些事情,而且比设计时的设计更有效率。它不是一个银弹,很多人可能永远不会使用它。但是一些设计模式或一些问题根本无法解决(至少不是有效的方式),而不使用新的RTTI

There is probably a lot of scenarios where it would be beneficial to use it. In short it adds dynamic aspect to your application. Your product is able to do some things at runtime, and more efficiently, than designing everything at designtime. It is not a silver bullet and a lot of people may never use it. But some design patterns or some problems just cannot be solved (at least not in efficient way) without the use of the new RTTI

这篇关于德尔福新型RTTI的实用性 - 属性,价值观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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