partial class User
{
[OnSerializing]
public void ClearPassword()
{
Password = null;
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.[User]")]
[global::System.Runtime.Serialization.DataContractAttribute()]
public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
{
[global::System.Runtime.Serialization.OnSerializingAttribute()]
[global::System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
public void OnSerializing(StreamingContext context)
{
this.serializing = true;
}
}
无效的属性。 'Void ClearPassword()'和'Void 类型中的OnSerializing(System.Runtime.Serialization.StreamingContext)' 'AuthenticationManager.User'有 'System.Runtime.Serialization.OnSerializingAttribute'。
现在,Microsoft的工程师是否为两个独立的代码块创建了一种方法,可以在序列化上相互独立地触发某些事件?特别考虑到他们劫持此事件以设置this.serializing = true
?
提前致谢。
答案 0 :(得分:1)
如果您的Password
媒体资源使用了支持字段you can set it to NonSerialized
[XmlIgnore]
[ScriptIgnore]
public string Password { get { return _password;} set { _password = value; } }
[NonSerialized]
private string _password;