public bool ReadRaw(XmlReader reader, SifVersion version, SifElement parent, SifFormatter formatter) { string name = reader.LocalName; if (name.Equals(fDateElement)) { String dateValue = ConsumeElementTextValue(reader, version); DateTime?date = formatter.ToDate(dateValue); if (date.HasValue) { DateTime tsValue = date.Value; SifDateTime dateTime = new SifDateTime(tsValue); parent.SetField(dateTime.CreateField(parent, fElementDef)); } } else if (name.Equals(fTimeElement)) { String timeValue = ConsumeElementTextValue(reader, version); DateTime?time = formatter.ToTime(timeValue); if (time.HasValue) { DateTime val = time.Value; // See if the Timestamp field already exists on the parent SimpleField timeStampField = parent.GetField(fElementDef); if (timeStampField == null) { // Doesn't exist, create it SifDateTime dateTime = new SifDateTime(val); parent.SetField(dateTime.CreateField(parent, fElementDef)); } else { // Exists, update the time portion of the date SifDateTime sdt = (SifDateTime)timeStampField.SifValue; if (sdt != null && sdt.Value.HasValue) { DateTime tsValue = sdt.Value.Value; tsValue = tsValue.Add(val.TimeOfDay); sdt = new SifDateTime(tsValue); // Overwrite the current value parent.SetField(sdt.CreateField(parent, fElementDef)); } } } } else { return(false); } return(true); }
public bool ReadRaw( XmlReader reader, SifVersion version, SifElement parent, SifFormatter formatter ) { string name = reader.LocalName; if ( name.Equals( fDateElement ) ) { String dateValue = ConsumeElementTextValue( reader, version ); DateTime? date = formatter.ToDate( dateValue ); if ( date.HasValue ) { DateTime tsValue = date.Value; SifDateTime dateTime = new SifDateTime( tsValue ); parent.SetField( dateTime.CreateField( parent, fElementDef ) ); } } else if ( name.Equals( fTimeElement ) ) { String timeValue = ConsumeElementTextValue( reader, version ); DateTime? time = formatter.ToTime( timeValue ); if ( time.HasValue ) { DateTime val = time.Value; // See if the Timestamp field already exists on the parent SimpleField timeStampField = parent.GetField( fElementDef ); if ( timeStampField == null ) { // Doesn't exist, create it SifDateTime dateTime = new SifDateTime( val ); parent.SetField( dateTime.CreateField( parent, fElementDef ) ); } else { // Exists, update the time portion of the date SifDateTime sdt = (SifDateTime) timeStampField.SifValue; if ( sdt != null && sdt.Value.HasValue ) { DateTime tsValue = sdt.Value.Value; tsValue = tsValue.Add( val.TimeOfDay ); sdt = new SifDateTime( tsValue ); // Overwrite the current value parent.SetField( sdt.CreateField( parent, fElementDef ) ); } } } } else { return false; } return true; }