数据契约事件
2012-04-17 17:19
323 查看
.NET数据契约DataContract提供4个事件
[OnDeserialized|OnDeserializing|OnSerialized|OnSerializing]
我们可以通过以上事件在序列化或反序列化时实现构造函数的功能
[OnDeserialized|OnDeserializing|OnSerialized|OnSerializing]
我们可以通过以上事件在序列化或反序列化时实现构造函数的功能
[DataContract] public class TestInfo { [DataMember(Name = "t1")] public int Test1{ get; set; } [DataMember(Name = "t2")] public string Test2{ get; set; } [OnDeserialized] void OnDeserialized(StreamingContext context) { if (this.Test2 == null) this.Test2 = "deserialized"; } [OnSerializing] void OnSerializing(StreamingContext context) { if (this.Test2 == null) this.Test2 = "serializing"; } }
相关文章推荐
- WCF学习 (四) 数据契约的事件
- WCF分布式开发步步为赢(7):WCF数据契约与序列化
- Flex spark.components.DataGrid与mx.controls.DataGrid邦定数据和项点击事件
- 先读数据再弹出对话框根据对话框的选择来触发事件 confirm button input
- Delphi XE2 之 FireMonkey 入门(30) - 数据绑定: TBindingsList: TBindExpression 的 OnAssigningValue 事件
- 21、数据结构笔记之十九列队实现离散事件模拟
- android 转屏幕事件保存数据--就一行代码
- Extjs4.1:由json数据生成icon列表并对单击事件弹出提示
- Oracle IO问题解析(六)—— 数据文件相关的IO事件
- 案例十一 、使用jQuery动态追加页面数据以及事件委托
- ms-repeat 数据渲染后触发事件
- MySQL mysqldump 导入/导出 结构&数据&存储过程&函数&事件&触发器
- T-SQL 使用链接库向mysql导数据遇到的奇葩事件一
- 微服务实践(五):微服务的事件驱动数据管理
- 多级下拉列表默认触发下拉事件加载数据
- android中通过网络请求数据显示在Listview中,面对许多的item,如何给每个item设置点击事件以跳转到不同的activity
- 数据绑定button,点击产生对应项事件
- Android中的使用ListView控件显示List集合中的数据,并对Item响应选择事件(方法二)
- Scott Mitchell 的ASP.NET 2.0数据教程之十七:: 研究插入、更新和删除的关联事件
- 那些年,我们一起学WCF--(5)数据契约继承