/// <summary>
        /// Parse ConformanceRestComponent
        /// </summary>
        public static Hl7.Fhir.Model.Conformance.ConformanceRestComponent ParseConformanceRestComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Conformance.ConformanceRestComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Conformance.ConformanceRestComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Conformance.ConformanceRestComponent();
            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 mode
                else if (atName == "mode")
                {
                    result.ModeElement = CodeParser.ParseCode <Hl7.Fhir.Model.Conformance.RestfulConformanceMode>(reader, errors);
                }

                // Parse element documentation
                else if (atName == "documentation")
                {
                    result.DocumentationElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element security
                else if (atName == "security")
                {
                    result.Security = ConformanceParser.ParseConformanceRestSecurityComponent(reader, errors);
                }

                // Parse element resource
                else if (atName == "resource")
                {
                    result.Resource = new List <Hl7.Fhir.Model.Conformance.ConformanceRestResourceComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "resource"))
                    {
                        result.Resource.Add(ConformanceParser.ParseConformanceRestResourceComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element batch
                else if (atName == "batch")
                {
                    result.BatchElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

                // Parse element history
                else if (atName == "history")
                {
                    result.HistoryElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

                // Parse element query
                else if (atName == "query")
                {
                    result.Query = new List <Hl7.Fhir.Model.Conformance.ConformanceRestQueryComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "query"))
                    {
                        result.Query.Add(ConformanceParser.ParseConformanceRestQueryComponent(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 SerializeConformanceRestComponent(Hl7.Fhir.Model.Conformance.ConformanceRestComponent 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 mode
            if (value.ModeElement != null)
            {
                writer.WriteStartElement("mode");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.Conformance.RestfulConformanceMode>(value.ModeElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element documentation
            if (value.DocumentationElement != null)
            {
                writer.WriteStartElement("documentation");
                FhirStringSerializer.SerializeFhirString(value.DocumentationElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element security
            if (value.Security != null)
            {
                writer.WriteStartElement("security");
                ConformanceSerializer.SerializeConformanceRestSecurityComponent(value.Security, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element resource
            if (value.Resource != null && value.Resource.Count > 0)
            {
                writer.WriteStartArrayElement("resource");
                foreach (var item in value.Resource)
                {
                    writer.WriteStartArrayMember("resource");
                    ConformanceSerializer.SerializeConformanceRestResourceComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element batch
            if (value.BatchElement != null)
            {
                writer.WriteStartElement("batch");
                FhirBooleanSerializer.SerializeFhirBoolean(value.BatchElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element history
            if (value.HistoryElement != null)
            {
                writer.WriteStartElement("history");
                FhirBooleanSerializer.SerializeFhirBoolean(value.HistoryElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element query
            if (value.Query != null && value.Query.Count > 0)
            {
                writer.WriteStartArrayElement("query");
                foreach (var item in value.Query)
                {
                    writer.WriteStartArrayMember("query");
                    ConformanceSerializer.SerializeConformanceRestQueryComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
        }