Example #1
0
        public static void SerializeUuid(Hl7.Fhir.Model.Uuid value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartComplexContent();

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

            // 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();
            }


            writer.WriteEndComplexContent();
        }
Example #2
0
 public static bool TryParse(string value, out Uuid result)
 {
     if(value==null ||Regex.IsMatch(value,"^" + PATTERN + "$", RegexOptions.Singleline))
     {
         result = new Uuid(value);
         return true;
     }
     else
     {
         result = null;
         return false;
     }
 }
Example #3
0
        /// <summary>
        /// Parse uuid
        /// </summary>
        public static Hl7.Fhir.Model.Uuid ParseUuid(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Uuid existingInstance = null)
        {
            Hl7.Fhir.Model.Uuid result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Uuid();
            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 value
                else if (atName == "value")
                {
                    result.Value = Uuid.Parse(reader.ReadPrimitiveContents(typeof(Uuid))).Value;
                }

                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);
        }