コード例 #1
0
        public static void SerializeDocumentInformationAttesterComponent(DocumentInformation.DocumentInformationAttesterComponent value, IFhirWriter writer)
        {
            writer.WriteStartComplexContent();

            // Serialize element's localId attribute
            if (value.InternalId != null && !String.IsNullOrEmpty(value.InternalId.Contents))
            {
                writer.WriteRefIdContents(value.InternalId.Contents);
            }

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

            // Serialize element mode
            if (value.Mode != null)
            {
                writer.WriteStartElement("mode");
                CodeSerializer.SerializeCode <DocumentInformation.DocumentAttestationMode>(value.Mode, writer);
                writer.WriteEndElement();
            }

            // Serialize element time
            if (value.Time != null)
            {
                writer.WriteStartElement("time");
                FhirDateTimeSerializer.SerializeFhirDateTime(value.Time, writer);
                writer.WriteEndElement();
            }

            // Serialize element party
            if (value.Party != null)
            {
                writer.WriteStartElement("party");
                ResourceReferenceSerializer.SerializeResourceReference(value.Party, writer);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
        }
コード例 #2
0
        /// <summary>
        /// Parse DocumentInformationAttesterComponent
        /// </summary>
        public static DocumentInformation.DocumentInformationAttesterComponent ParseDocumentInformationAttesterComponent(IFhirReader reader, ErrorList errors, DocumentInformation.DocumentInformationAttesterComponent existingInstance = null)
        {
            DocumentInformation.DocumentInformationAttesterComponent result = existingInstance != null ? existingInstance : new DocumentInformation.DocumentInformationAttesterComponent();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

                while (reader.HasMoreElements())
                {
                    // Parse element extension
                    if (ParserUtils.IsAtFhirElement(reader, "extension"))
                    {
                        result.Extension = new List <Extension>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element internalId
                    else if (reader.IsAtRefIdElement())
                    {
                        result.InternalId = Id.Parse(reader.ReadRefIdContents());
                    }

                    // Parse element mode
                    else if (ParserUtils.IsAtFhirElement(reader, "mode"))
                    {
                        result.Mode = CodeParser.ParseCode <DocumentInformation.DocumentAttestationMode>(reader, errors);
                    }

                    // Parse element time
                    else if (ParserUtils.IsAtFhirElement(reader, "time"))
                    {
                        result.Time = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                    }

                    // Parse element party
                    else if (ParserUtils.IsAtFhirElement(reader, "party"))
                    {
                        result.Party = ResourceReferenceParser.ParseResourceReference(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();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }