protected void Validate(CDate cDate) { this.ValidateBase((CPrimitive)cDate); if (cDate.MonthValidity != null) { this.Validate(cDate.MonthValidity); Invariant(cDate.MonthValidity.value != 1002 || (cDate.DayValidity.value == 1002 || cDate.DayValidity.value == 1003), "cDate.MonthValidity is optional, means DayValidity must be either optional or disallowed."); Invariant(cDate.MonthValidity.value != 1003 || cDate.DayValidity.value == 1003, "cDate.MonthValidity is disallowed, implies cDate.DayValidity must be disallowed."); } }
private void WriteXml(CDate cPrimitive) { if (!string.IsNullOrEmpty(cPrimitive.Pattern)) writer.WriteElementString("pattern", OpenEhrNamespace, cPrimitive.Pattern); if (cPrimitive.TimezoneValidity != null) writer.WriteElementString("timezone_validity", OpenEhrNamespace, cPrimitive.TimezoneValidity.Value.ToString()); if (cPrimitive.Range != null) this.WriteXml(cPrimitive.Range); if (cPrimitive.AssumedValue != null) { writer.WriteStartElement(UseOpenEhrPrefix(writer), "assumed_value", OpenEhrNamespace); writer.WriteString(cPrimitive.AssumedValue.ToString()); writer.WriteEndElement(); } }
internal static OpenEhr.AM.Archetype.ConstraintModel.Primitive.CPrimitive CPrimitive(string typeName) { DesignByContract.Check.Require(!string.IsNullOrEmpty(typeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "typeName")); OpenEhr.AM.Archetype.ConstraintModel.Primitive.CPrimitive cPrimitive = null; switch (typeName) { case "C_BOOLEAN": cPrimitive = new CBoolean(); break; case "C_DATE": cPrimitive = new CDate(); break; case "C_DATE_TIME": cPrimitive = new CDateTime(); break; case "C_DURATION": cPrimitive = new CDuration(); break; case "C_TIME": cPrimitive = new CTime(); break; case "C_INTEGER": cPrimitive = new CInteger(); break; case "C_REAL": cPrimitive = new CReal(); break; case "C_STRING": cPrimitive = new CString(); break; default: throw new NotSupportedException("type not supported: " + typeName); } DesignByContract.Check.Ensure(cPrimitive != null, "cObject must not be null."); return cPrimitive; }
private void ReadXml(CDate cDate) { Check.Require(cDate != null, "cDate must not be null."); reader.ReadStartElement(); reader.MoveToContent(); if (reader.LocalName == "pattern") { cDate.Pattern = reader.ReadElementContentAsString("pattern", OpenEhrNamespace); reader.MoveToContent(); } if (reader.LocalName == "timezone_validity") { cDate.TimezoneValidity = new ValidityKind(reader.ReadElementContentAsInt("timezone_validity", OpenEhrNamespace)); reader.MoveToContent(); } if (reader.LocalName == "range") { cDate.Range = new Interval<Iso8601Date>(); this.ReadXml(cDate.Range); } if (reader.LocalName == "assumed_value") { cDate.AssumedValue = new AssumedTypes.Iso8601Date(reader.ReadElementContentAsString("assumed_value", OpenEhrNamespace)); reader.MoveToContent(); } reader.ReadEndElement(); reader.MoveToContent(); }