钩到OnDeserializing为XmlSerializer的 [英] Hook in to OnDeserializing for XmlSerializer

查看:169
本文介绍了钩到OnDeserializing为XmlSerializer的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除根据指出,这个帖子我乐意做一个XmlSerializer开始反序列化(未完成时反序列化)

Otherwise than pointed out in this post I would like to act just before an XmlSerializer starts deserializing (not when finished deserializing)

背景之前:我有一个基类实现 INotifyPropertyChanged的。这是的BaseClass以XML格式存储在数据库中,检索时反序列化为对象实例。反序列化执行这个类在我的ChangeNotification发生的制定者。在为changenotification一个集中处理我设置对象的状态和跟踪栈取消更改。显然,我不希望这些反序列化到过程中trigerred。

Background: I have a baseClass that implements INotifyPropertyChanged. This BaseClass is stored as xml in a database and when retrieved deserialized into an object instance. The deserialization executes the setters of this class where my ChangeNotification takes place. On a centralised handler for the changenotification I set the status of the object and keep track of stacks for undoing changes. Apparently I don't want these to be trigerred during deserialization.

任何想法将是非常欢迎!

Any ideas would be very welcome!

推荐答案

作为评论@马克的解决方案。现在最务实的方式(我开发的概念为复杂的功能一大块证明)是默认对象已经反序列化一个简单的公共无效后。在这种方法我可以清空撤消堆栈并设置对象不变的状态。

As commented @ Marc's solution. The most pragmatic way right now (I'm developing a proof of concept for a big chunk of complex functionality) is to default the object after it has been deserialized with a simple public void. In this method I can empty the undo stack and set the status of the object to unchanged.

如果我想出一些更好的想法,我会张贴在这里。

If I come up with some better ideas I'll post them here.

这篇关于钩到OnDeserializing为XmlSerializer的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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