public override void WriteXmlAttributes(XmlWriter xmlWriter)
        {
            xmlWriter.WriteAttributeString("Id", XmlConvert.ToString(Id));
            xmlWriter.WriteAttributeString("Timestamp", XmlConvert.ToString(Timestamp));
            xmlWriter.WriteAttributeString("State", State);
            xmlWriter.WriteAttributeString("ValidFromDateTime", XmlConvert.ToString(ValidFromDateTime));
            if (InvalidFromDateTime.HasValue)
            {
                xmlWriter.WriteAttributeString("InvalidFromDateTime", XmlConvert.ToString(InvalidFromDateTime.Value));
            }

            if (DatedVehicleJourneyRef != null)
            {
                xmlWriter.WriteStartElement("DatedVehicleJourneyRef");
                DatedVehicleJourneyRef.WriteXmlAttributes(xmlWriter);
                xmlWriter.WriteEndElement();
            }

            if (AssignedVehicleRef != null)
            {
                xmlWriter.WriteStartElement("AssignedVehicleRef");
                AssignedVehicleRef.WriteXmlAttributes(xmlWriter);
                xmlWriter.WriteEndElement();
            }
        }
        public override void ReadXml(XElement xml)
        {
            Id                = long.Parse(xml.Attribute("Id").Value);
            Timestamp         = DateTimeOffset.Parse(xml.Attribute("Timestamp").Value);
            State             = xml.Attribute("State").Value;
            ValidFromDateTime = DateTimeOffset.Parse(xml.Attribute("ValidFromDateTime").Value);
            if (xml.Attribute("InvalidFromDateTime") != null)
            {
                InvalidFromDateTime = DateTimeOffset.Parse(xml.Attribute("InvalidFromDateTime").Value);
            }

            DatedVehicleJourneyRef = DatedVehicleJourneyRef.ReadFromXml(xml.Element("DatedVehicleJourneyRef"));
            AssignedVehicleRef     = VehicleRef.ReadFromXml(xml.Element("AssignedVehicleRef"));
        }
Esempio n. 3
0
        public override void ReadXmlElement(XElement el)
        {
            switch (el.Name.LocalName)
            {
            case "DatedVehicleJourneyRef":
                DatedVehicleJourneyRef = DatedVehicleJourneyRef.ReadFromXml(el);
                break;

            case "MonitoredVehicleJourneyRef":
                MonitoredVehicleJourneyId = long.Parse(el.Attribute("Id").Value);
                break;

            case "TargetJourneyPatternPointRef":
                TargetJourneyPatternPointGid = long.Parse(el.Attribute("Gid").Value);
                break;

            case "TimetabledJourneyPatternPointRef":
                TimetabledJourneyPatternPointGid = long.Parse(el.Attribute("Gid").Value);
                break;
            }
        }
        public static DatedVehicleJourneyRef ReadFromXml(XElement xml, bool required = false)
        {
            if (xml == null && !required)
            {
                return(null);
            }

            var datedVehicleJourneyRef = new DatedVehicleJourneyRef();

            if (long.TryParse(xml.Attribute("Id")?.Value, out var id))
            {
                datedVehicleJourneyRef.Id = id;
            }
            if (DateTime.TryParse(xml.Attribute("OperatingDayDate")?.Value, out var operatingDayDate))
            {
                datedVehicleJourneyRef.OperatingDayDate = operatingDayDate;
            }
            if (long.TryParse(xml.Attribute("Gid")?.Value, out var gid))
            {
                datedVehicleJourneyRef.Gid = gid;
            }

            return(datedVehicleJourneyRef);
        }