3
我需要序列化Windows Phone 7項目中的派生類以獲得邏輯刪除狀態。 但我無法訪問基本類的代碼 - 由庫顯示 - 。序列化派生類,但不訪問基類
//don't have access to this class
public class A
{
public string member1 {get;set;}
}
[DataContract]
public class B : A
{
public B(){}; //CTOR
[DataMember]
public string member2 {get;set;}
}
當系統嘗試序列(我將它保存到PhoneApplicationPage.State =>所以它的自動序列化):它不工作,例外(InvalidDataContractException)說:「類型‘B’不能從類型繼承沒有用DataContractAttribute或SerializableAttribute標記,考慮使用DataContractAttribute或SerializableAttribute標記基本類型'A',或者從派生類型中刪除它們。
我應該實現一個自定義串行器嗎?我怎樣才能做到這一點(在Windows Phone 7的)