private void WriteAddress(string elementName, GpxAddress address) { Writer_.WriteStartElement(elementName, GpxNamespaces.GARMIN_WAYPOINT_EXTENSIONS_NAMESPACE); if (address.StreetAddress != null) { Writer_.WriteElementString("StreetAddress", GpxNamespaces.GARMIN_WAYPOINT_EXTENSIONS_NAMESPACE, address.StreetAddress); } if (address.City != null) { Writer_.WriteElementString("City", GpxNamespaces.GARMIN_WAYPOINT_EXTENSIONS_NAMESPACE, address.City); } if (address.State != null) { Writer_.WriteElementString("State", GpxNamespaces.GARMIN_WAYPOINT_EXTENSIONS_NAMESPACE, address.State); } if (address.Country != null) { Writer_.WriteElementString("Country", GpxNamespaces.GARMIN_WAYPOINT_EXTENSIONS_NAMESPACE, address.Country); } if (address.PostalCode != null) { Writer_.WriteElementString("PostalCode", GpxNamespaces.GARMIN_WAYPOINT_EXTENSIONS_NAMESPACE, address.PostalCode); } Writer_.WriteEndElement(); }
private GpxAddress ReadGarminGpxAddress() { GpxAddress address = new GpxAddress(); if (Reader_.IsEmptyElement) { return(address); } string elementName = Reader_.Name; while (Reader_.Read()) { switch (Reader_.NodeType) { case XmlNodeType.Element: switch (Reader_.LocalName) { case "StreetAddress": if (string.IsNullOrEmpty(address.StreetAddress)) { address.StreetAddress = ReadContentAsString(); break; } address.StreetAddress += " " + ReadContentAsString(); break; case "City": address.City = ReadContentAsString(); break; case "State": address.State = ReadContentAsString(); break; case "Country": address.Country = ReadContentAsString(); break; case "PostalCode": address.PostalCode = ReadContentAsString(); break; default: SkipElement(); break; } break; case XmlNodeType.EndElement: if (Reader_.Name != elementName) { throw new FormatException(Reader_.Name); } return(address); } } throw new FormatException(elementName); }