/// <summary> /// Parse SecurityEvent /// </summary> public static Hl7.Fhir.Model.SecurityEvent ParseSecurityEvent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.SecurityEvent existingInstance = null) { Hl7.Fhir.Model.SecurityEvent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.SecurityEvent(); 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 language else if (atName == "language") { result.LanguageElement = CodeParser.ParseCode(reader, errors); } // Parse element text else if (atName == "text") { result.Text = NarrativeParser.ParseNarrative(reader, errors); } // Parse element contained else if (atName == "contained") { result.Contained = new List <Hl7.Fhir.Model.Resource>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "contained")) { result.Contained.Add(ParserUtils.ParseContainedResource(reader, errors)); } reader.LeaveArray(); } // Parse element _id else if (atName == "_id") { result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); } // Parse element event else if (atName == "event") { result.Event = SecurityEventParser.ParseSecurityEventEventComponent(reader, errors); } // Parse element participant else if (atName == "participant") { result.Participant = new List <Hl7.Fhir.Model.SecurityEvent.SecurityEventParticipantComponent>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "participant")) { result.Participant.Add(SecurityEventParser.ParseSecurityEventParticipantComponent(reader, errors)); } reader.LeaveArray(); } // Parse element source else if (atName == "source") { result.Source = SecurityEventParser.ParseSecurityEventSourceComponent(reader, errors); } // Parse element object else if (atName == "object") { result.Object = new List <Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "object")) { result.Object.Add(SecurityEventParser.ParseSecurityEventObjectComponent(reader, errors)); } reader.LeaveArray(); } 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); }
public static void SerializeSecurityEvent(Hl7.Fhir.Model.SecurityEvent value, IFhirWriter writer, bool summary) { writer.WriteStartRootObject("SecurityEvent"); 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 language if (value.LanguageElement != null && !summary) { writer.WriteStartElement("language"); CodeSerializer.SerializeCode(value.LanguageElement, writer, summary); writer.WriteEndElement(); } // Serialize element text if (value.Text != null && !summary) { writer.WriteStartElement("text"); NarrativeSerializer.SerializeNarrative(value.Text, writer, summary); writer.WriteEndElement(); } // Serialize element contained if (value.Contained != null && !summary && value.Contained.Count > 0) { writer.WriteStartArrayElement("contained"); foreach (var item in value.Contained) { writer.WriteStartArrayMember("contained"); FhirSerializer.SerializeResource(item, writer, summary); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element event if (value.Event != null && !summary) { writer.WriteStartElement("event"); SecurityEventSerializer.SerializeSecurityEventEventComponent(value.Event, writer, summary); writer.WriteEndElement(); } // Serialize element participant if (value.Participant != null && !summary && value.Participant.Count > 0) { writer.WriteStartArrayElement("participant"); foreach (var item in value.Participant) { writer.WriteStartArrayMember("participant"); SecurityEventSerializer.SerializeSecurityEventParticipantComponent(item, writer, summary); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element source if (value.Source != null && !summary) { writer.WriteStartElement("source"); SecurityEventSerializer.SerializeSecurityEventSourceComponent(value.Source, writer, summary); writer.WriteEndElement(); } // Serialize element object if (value.Object != null && !summary && value.Object.Count > 0) { writer.WriteStartArrayElement("object"); foreach (var item in value.Object) { writer.WriteStartArrayMember("object"); SecurityEventSerializer.SerializeSecurityEventObjectComponent(item, writer, summary); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } writer.WriteEndComplexContent(); writer.WriteEndRootObject(); }