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(ConstraintRef constraintRef) { this.ValidateBase((CObject)constraintRef); Invariant(constraintRef.Reference != null, string.Format( CommonStrings.XMustNotBeNull, "ConstraintRef.Reference")); // TODO: Consistency: not any_allowed }
private void ReadXml(ConstraintRef constraintRef) { Check.Require(constraintRef != null, string.Format(CommonStrings.XMustNotBeNull, "constraintRef")); reader.ReadStartElement(); reader.MoveToContent(); this.ReadXmlBase((CObject)constraintRef); string openEhrNamespace = RmXmlSerializer.OpenEhrNamespace; if (reader.LocalName != "reference") throw new InvalidXmlException("reference", reader.LocalName); constraintRef.Reference = reader.ReadElementContentAsString("reference", openEhrNamespace); reader.MoveToContent(); DesignByContract.Check.Assert(!string.IsNullOrEmpty(constraintRef.Reference), "Reference must not be null or empty."); DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement, "Expected endElement"); reader.ReadEndElement(); reader.MoveToContent(); }
private void WriteXml(ConstraintRef constraintRef) { Check.Require(constraintRef != null, string.Format(CommonStrings.XMustNotBeNull, "constraintRef")); Check.Require(!string.IsNullOrEmpty(constraintRef.Reference), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "constraintRef.Reference")); this.WriteXmlBase((CObject)constraintRef); writer.WriteElementString(UseOpenEhrPrefix(writer), "reference", OpenEhrNamespace, constraintRef.Reference); }