こんにちは、次の逆シリアル化コードがあります
public static T DeserializeXML<T>(String xml) where T : class
{
T newObject = null;
XmlSerializer s = new XmlSerializer(typeof(T));
using (StringReader sw = new StringReader(xml))
{
newObject = (T)s.Deserialize(sw);
}
return newObject;
}
デシリアライズしようとする私のメッセージ
<Data>
<ItemIn date="2012-08-09T10:25:54.06+01:00" itemId="000007721" Id="1"> <Extensions><Info Id="parts" order="issue"/></Extensions></ItemIn>
</Data>
しかし、私Extensions
はいつもnull
そこにいる元のクラスに部分的に逆シリアル化されることはありません。クラスの残りの部分は問題ありません。
何をチェックするべきか提案はありますか?
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class ItemTransferIn {
private Extensions extensions;
private System.DateTime date;
private string itemId;
private string Id;
/// <remarks/>
public ItemTransferInExtensions Extensions {
get {
return this.extensions;
}
set {
this.extensions = value;
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class Extensions {
private RecipeInfo recipeInfoField;
/// <remarks/>
public RecipeInfo RecipeInfo {
get {
return this.recipeInfoField;
}
set {
this.recipeInfoField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class RecipeInfo {
private string recipeIdField;
private string orderIdField;
private string itemBarcodeIdField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string Id {
get {
return this.recipeIdField;
}
set {
this.recipeIdField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string order {
get {
return this.orderIdField;
}
set {
this.orderIdField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string itemBarcodeId {
get {
return this.itemBarcodeIdField;
}
set {
this.itemBarcodeIdField = value;
}
}
}