/// <summary>
        /// Parse LocationPositionComponent
        /// </summary>
        public static Hl7.Fhir.Model.Location.LocationPositionComponent ParseLocationPositionComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Location.LocationPositionComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Location.LocationPositionComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Location.LocationPositionComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "extension"))
                    {
                        result.Extension.Add(ExtensionParser.ParseExtension(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element longitude
                else if (atName == "longitude")
                {
                    result.LongitudeElement = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                }

                // Parse element latitude
                else if (atName == "latitude")
                {
                    result.LatitudeElement = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                }

                // Parse element altitude
                else if (atName == "altitude")
                {
                    result.AltitudeElement = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                }

                else
                {
                    errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                    reader.SkipSubElementsFor(currentElementName);
                    result = null;
                }
            }

            reader.LeaveElement();
            return(result);
        }
예제 #2
0
        public static void SerializeLocationPositionComponent(Hl7.Fhir.Model.Location.LocationPositionComponent value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartComplexContent();

            // Serialize element _id
            if (value.LocalIdElement != null)
            {
                writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute);
            }

            // Serialize element extension
            if (value.Extension != null && !summary && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element longitude
            if (value.LongitudeElement != null)
            {
                writer.WriteStartElement("longitude");
                FhirDecimalSerializer.SerializeFhirDecimal(value.LongitudeElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element latitude
            if (value.LatitudeElement != null)
            {
                writer.WriteStartElement("latitude");
                FhirDecimalSerializer.SerializeFhirDecimal(value.LatitudeElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element altitude
            if (value.AltitudeElement != null)
            {
                writer.WriteStartElement("altitude");
                FhirDecimalSerializer.SerializeFhirDecimal(value.AltitudeElement, writer, summary);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
        }