internal static CObject CObject(string typeName) { DesignByContract.Check.Require(!string.IsNullOrEmpty(typeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "typeName")); CObject cObject = null; switch (typeName) { case "C_COMPLEX_OBJECT": cObject = new CComplexObject(); break; case "C_PRIMITIVE_OBJECT": cObject = new CPrimitiveObject(); break; case "ARCHETYPE_INTERNAL_REF": cObject = new ArchetypeInternalRef(); break; case "CONSTRAINT_REF": cObject = new ConstraintRef(); break; case "ARCHETYPE_SLOT": cObject = new ArchetypeSlot(); break; case "C_CODE_PHRASE": cObject = new CCodePhrase(); break; case "C_DV_STATE": cObject = new CDvState(); break; case "C_DV_ORDINAL": cObject = new CDvOrdinal(); break; case "C_DV_QUANTITY": cObject = new CDvQuantity(); break; default: throw new NotSupportedException("type not supported: " + typeName); } DesignByContract.Check.Ensure(cObject != null, "cObject must not be null."); return cObject; }
protected void Validate(CCodePhrase cCodePhrase) { this.Validate((CDomainType)cCodePhrase); Invariant(cCodePhrase.CodeList == null || (!cCodePhrase.CodeList.IsEmpty() && cCodePhrase.TerminologyId != null), "cCodePhrase.CodeList is not null, implies it must not be empty and terminologyId must not be null."); Invariant(cCodePhrase.AnyAllowed() ^ cCodePhrase.TerminologyId != null, "cCodePhrase.AnyAllowed xor cCodePhrase.TerminologyId must not be null."); }
private void WriteXml(CCodePhrase cDomainType) { string openEhrPrefix = UseOpenEhrPrefix(writer); this.WriteXmlBase((CObject)cDomainType); if (cDomainType.AssumedValue != null) { writer.WriteStartElement(openEhrPrefix, "assumed_value", OpenEhrNamespace); ((CodePhrase)(cDomainType.AssumedValue)).WriteXml(writer); writer.WriteEndElement(); } if (cDomainType.TerminologyId != null) { writer.WriteStartElement(openEhrPrefix, "terminology_id", OpenEhrNamespace); cDomainType.TerminologyId.WriteXml(writer); writer.WriteEndElement(); } if (cDomainType.CodeList != null) { foreach (string listItem in cDomainType.CodeList) { writer.WriteElementString(openEhrPrefix, "code_list", OpenEhrNamespace, listItem); } } }
private void ReadXml(CCodePhrase cDomainType) { reader.ReadStartElement(); reader.MoveToContent(); this.ReadXmlBase((CObject)cDomainType); if (reader.LocalName == "assumed_value") { CodePhrase assumedValue = new CodePhrase(); assumedValue.ReadXml(reader); cDomainType.AssumedValue = assumedValue; } if (reader.LocalName == "terminology_id") { cDomainType.TerminologyId = new TerminologyId(); cDomainType.TerminologyId.ReadXml(reader); } if (reader.LocalName == "code_list") { OpenEhr.AssumedTypes.List<string> codeList = new OpenEhr.AssumedTypes.List<string>(); do { string codeString = reader.ReadElementContentAsString("code_list", OpenEhrNamespace); reader.MoveToContent(); codeList.Add(codeString); } while (reader.LocalName == "code_list"); Check.Assert(!codeList.IsEmpty(), "codeList must not be empty."); cDomainType.CodeList = codeList; } reader.ReadEndElement(); reader.MoveToContent(); }