/// <summary> /// Parse uri /// </summary> public static Hl7.Fhir.Model.FhirUri ParseFhirUri(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.FhirUri existingInstance = null) { Hl7.Fhir.Model.FhirUri result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.FhirUri(); 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 = FhirUri.Parse(reader.ReadPrimitiveContents(typeof(FhirUri))).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); }
public void OIDandUUIDUrls() { var oidUrl = "urn:oid:1.2.3"; var illOidUrl = "urn:oid:datmagdusniet"; var uuidUrl = "urn:uuid:a5afddf4-e880-459b-876e-e4591b0acc11"; var illUuidUrl = "urn:uuid:ooknietgoed"; FhirUri uri = FhirUri.Parse(oidUrl); Assert.AreEqual(0, uri.Validate().Count); uri = FhirUri.Parse(illOidUrl); Assert.AreEqual(1, uri.Validate().Count); uri = FhirUri.Parse(uuidUrl); Assert.AreEqual(0, uri.Validate().Count); uri = FhirUri.Parse(illUuidUrl); Assert.AreEqual(1, uri.Validate().Count); Assert.IsTrue(Uri.Equals(new Uri("http://nu.nl"), new Uri("http://nu.nl"))); }