2011-11-21 74 views
0

我有一個XML文檔,其中包含一個類似於此的節點。如何在Windows Phone 7中使用DataContract反序列化XML屬性

<channel id="3102" platform = "1" activation="30/11/2010" desactivation=""> 

而且我想用DataContract反序列化IT和數據成員屬性,這與它的性能運作良好但不反序列化的屬性。

[DataContract(Namespace="")] 
[XmlSerializerFormat]  
public abstract class Channel 
{ 
    #region variables privadas 

     [DataContract(Namespace="")] 
[XmlSerializerFormat]  
//[KnownType(typeof(AudioChannel))] 
//[KnownType(typeof(VideoChannel))] 
public abstract class Channel 
{ 
    #region variables privadas 

    private DateTime _desactivation; 
    private DateTime _activation; 
    private int _platform; 
    private int _id; 
    .... 
    #endregion 

    #region Propiedades públicas 

    [DataMember] 
    [XmlAttribute(AttributeName="desactivation")] 
    public DateTime Desactivation 
    { 
     get { return _desactivation; } 
     set { _desactivation = value; } 
    } 

    [DataMember] 
    [XmlAttribute(AttributeName="activation")] 
    public DateTime Activation 
    { 
     get { return _activation; } 
     set { _activation = value; } 
    } 

    [DataMember] 
    [XmlAttribute(AttributeName="platform")] 
    public int Platform 
    { 
     get { return _platform; } 
     set { _platform = value; } 
    } 
    #endregion 

    #region Propiedades públicas 

    [DataMember] 
    [XmlAttribute(AttributeName="desactivation")] 
    public DateTime Desactivation 
    { 
     get { return _desactivation; } 
     set { _desactivation = value; } 
    } 

    [DataMember] 
    [XmlAttribute(AttributeName="activation")] 
    public DateTime Activation 
    { 
     get { return _activation; } 
     set { _activation = value; } 
    } 

    [DataMember] 
    [XmlAttribute(AttributeName="platform")] 
    public int Platform 
    { 
     get { return _platform; } 
     set { _platform = value; } 
    } ... 

我的與這些屬性相關的屬性沒有填充,我做錯了什麼?

在此先感謝您提供的任何幫助。

+0

「flatform」看起來很糟糕。 –

+0

請發佈您用於反序列化xml的代碼。 – calum

回答