非序列化字段与反序列化完成后回调

示例:

public class Class1 : IDeserializationCallback
{
    public DateTime Birthday { get; set; }
    [NonSerialized]
    public int Age;
    public void OnDeserialization(object sender)
    {
        Age = DateTime.Now.Year - Birthday.Year;
    }
}

 

posted on 2013-07-21 14:34  yao2yao4  阅读(194)  评论(0编辑  收藏  举报

导航