Delphi组件序列化 [英] Delphi Component Serialization

查看:118
本文介绍了Delphi组件序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人遇到将组件序列化到文件中并将其读回来的问题,特别是在组件供应商升级VCL组件的区域。例如,使用DelphiX序列化的文件,然后几年后用delphiY回读。序列化格式发生变化,如果是这样,可以做什么来防止升级时错误读取组件。

Has anyone run into issues serializing components into a file and reading them back, specifically in the area where the component vendor upgrades the VCL components. For example a file serialized with DelphiX and then years later read back with delphiY. Do the serialization formats change and if so what can be done to prevent errors reading in the componets when upgrading.

推荐答案

在基于RTTI的系统中,用于序列化已发布的属性容易受到组件变化的影响。只要旧的属性保存在新对象中,前进是可管理的。即你离开属性界面是,但如果你喜欢可以折腾的内容。反向更糟糕 - 因为较旧版本的存储属性无法在旧版本加载中打开,这将是一个问题。

The built-in RTTI based system for serializing published properties is vulnerable to changes in the components. Going forwards is manageable as long as old properties are kept in new objects. I.e. you leave the property interface as is, but can toss away the contents if you like. Going backwards is worse - as a newer version saved property can't be opened in older version load, and that will be a problem.

有组件/ libs(< a href =http://www.torry.net/quicksearchd.php?String=RTTI&Title=Yes =nofollow noreferrer> http://www.torry.net/quicksearchd.php?String=RTTI& ; Title = Yes ),可以添加XML格式的序列化,这可能有所帮助,您可以选择跳过您不知道的内容。

There are components / libs (http://www.torry.net/quicksearchd.php?String=RTTI&Title=Yes) that can add serialization in XML format and this may help a bit as you can choose to skip content you don't know.

您仍然需要注意如何设计发布的内容,并且应该可能会找到一种方法来忽略但传播当前版本不了解的内容。这将允许您在尝试保留较新的属性,而不是剥离它们时,以较新的格式打开和更改文件。

You still need to be mindful about how you design your published content and should probably find a way to "ignore but propagate" content that your current version don't understand. This will allow you to open and change a file in a newer format while attempting to keep newer attributes, instead of stripping them.

这篇关于Delphi组件序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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