C# 对象序列化成xml格式的时候指定日期型(DateTime)属性的序列化格式
[Serializable]
[XmlRoot(ElementName = "item")]
public class MneProductSourceImage
{
[XmlElement(ElementName = "productid")]
public int productid { get; set; }
[XmlIgnore]
public Date imagetime { get; set; }
[XmlElement(ElementName = "imagetime")]
public String ProxyImageTime
{
get
{
return imagetime.ToString("yyyy-MM-dd HH:mm:ss");
}
set
{
imagetime = Date.Parse(value);
}
}
[XmlIgnore ]
public Date istoptime { get; set; }
[XmlElement(ElementName = "istoptime")]
public String ProxyIstoptime
{
get
{
return istoptime.ToString("yyyy-MM-dd HH:mm:ss");
}
set
{
istoptime = Date.Parse(value);
}
}
[XmlElement(ElementName = "width")]
public int width { get; set; }
[XmlElement(ElementName = "height")]
public int height { get; set; }
}
[XmlRoot(ElementName = "item")]
public class MneProductSourceImage
{
[XmlElement(ElementName = "productid")]
public int productid { get; set; }
[XmlIgnore]
public Date imagetime { get; set; }
[XmlElement(ElementName = "imagetime")]
public String ProxyImageTime
{
get
{
return imagetime.ToString("yyyy-MM-dd HH:mm:ss");
}
set
{
imagetime = Date.Parse(value);
}
}
[XmlIgnore ]
public Date istoptime { get; set; }
[XmlElement(ElementName = "istoptime")]
public String ProxyIstoptime
{
get
{
return istoptime.ToString("yyyy-MM-dd HH:mm:ss");
}
set
{
istoptime = Date.Parse(value);
}
}
[XmlElement(ElementName = "width")]
public int width { get; set; }
[XmlElement(ElementName = "height")]
public int height { get; set; }
}