I'm having trouble adjusting how DateTime variables are serialized in my objects. I want it to be output as 2011-09-26T13: 00: 00Z, but when I redefine the GetObjectData () function, I think this is the way to do this, the XML data for them is not output at all.
[DataContract(Namespace = "")] [XmlRootAttribute(Namespace = "http://www.w3.org/2005/Atom", ElementName = "feed")] public class GCal { [XmlNamespaceDeclarations] public XmlSerializerNamespaces _xsns = new XmlSerializerNamespaces(); [XmlElement(ElementName = "entry")] public Collection<MMU.Calendar.gCalEvent> items = new Collection<MMU.Calendar.gCalEvent>(); } public class gCalEvent { [XmlElement(Namespace = "http://schemas.google.com/g/2005")] public gdEvent when = new gdEvent(); } public class gdEvent : ISerializable { [XmlAttribute(AttributeName = "startTime")] private DateTime _startTime; [XmlAttribute(AttributeName = "endTime")] private DateTime _endTime; public gdEvent(DateTime startTime, DateTime endTime) { _startTime = startTime; _endTime = endTime; } public gdEvent() { _startTime = DateTime.MinValue; _endTime = DateTime.MinValue; } [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] public virtual void GetObjectData(SerializationInfo info, StreamingContext context) {
I tried to view this information, but there seems to be a lot about custom serialization for files, but not in XML ...
source share