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(CDvOrdinal cDvOrdinal) { this.Validate((CDomainType)cDvOrdinal); Invariant(cDvOrdinal.List == null || !cDvOrdinal.List.IsEmpty(), "cDvOrdinal.List is not null, implies it must not be empty."); Invariant(cDvOrdinal.AnyAllowed() ^ cDvOrdinal.List != null, "cDvOrdinal.AnyAllowed() XOR cDvOrdinal.List != null."); if (cDvOrdinal.List != null) { foreach (DvOrdinal dvOrdinal in cDvOrdinal.List) this.Validate(dvOrdinal); } }
private void WriteXml(CDvOrdinal cDomainType) { this.WriteXmlBase((CObject)cDomainType); if (cDomainType.AssumedValue != null) { writer.WriteStartElement(UseOpenEhrPrefix(writer), "assumed_value", OpenEhrNamespace); ((DvOrdinal)(cDomainType.AssumedValue)).WriteXml(writer); writer.WriteEndElement(); } if (cDomainType.List == null) //Added by LMT 05/Apr/2009 EHR-900 return; foreach (DvOrdinal listItem in cDomainType.List) { writer.WriteStartElement(UseOpenEhrPrefix(writer), "list", OpenEhrNamespace); listItem.WriteXml(writer); writer.WriteEndElement(); } }
private void ReadXml(CDvOrdinal cDomainType) { reader.ReadStartElement(); reader.MoveToContent(); this.ReadXmlBase((CObject)cDomainType); if (reader.LocalName == "assumed_value") { DvOrdinal assumedValue = new DvOrdinal(); assumedValue.ReadXml(reader); cDomainType.AssumedValue = assumedValue; } if (reader.LocalName == "list") { System.Collections.Generic.List<DvOrdinal> ordinalList = new System.Collections.Generic.List<DvOrdinal>(); do { DvOrdinal ordinal = new DvOrdinal(); ordinal.ReadXml(reader); ordinalList.Add(ordinal); } while (reader.LocalName == "list" && reader.NodeType== XmlNodeType.Element); Check.Assert(ordinalList.Count>0, "ordinalList may not be empty."); cDomainType.List = new Set<DvOrdinal>(ordinalList); } reader.ReadEndElement(); reader.MoveToContent(); }