protected void Validate(CString cString) { this.ValidateBase((CPrimitive)cString); Invariant(cString.Pattern != null ^ cString.List != null, CommonStrings.CStringListXorPattern); Invariant(cString.Pattern == null || cString.Pattern != string.Empty, string.Format(CommonStrings.IfXIsNotNullMustBeEmpty, "CString.Pattern")); }
private void WriteXml(CString cPrimitive) { if (!string.IsNullOrEmpty(cPrimitive.Pattern)) writer.WriteElementString("pattern", OpenEhrNamespace, cPrimitive.Pattern); if (cPrimitive.List != null && cPrimitive.List.Count > 0) { foreach (string item in cPrimitive.List) { writer.WriteElementString("list", OpenEhrNamespace, item); } } if (cPrimitive.listOpenSet) writer.WriteElementString("list_open", OpenEhrNamespace, cPrimitive.ListOpen.ToString().ToLower()); if (cPrimitive.AssumedValue != null && cPrimitive.AssumedValue.ToString() != string.Empty) writer.WriteElementString("assumed_value", OpenEhrNamespace, cPrimitive.AssumedValue.ToString()); }
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(CString cString) { reader.ReadStartElement(); reader.MoveToContent(); if (reader.LocalName == "pattern") { cString.Pattern = reader.ReadElementContentAsString("pattern", OpenEhrNamespace); reader.MoveToContent(); } if (reader.LocalName == "list") { System.Collections.Generic.List<string> stringList = new System.Collections.Generic.List<string>(); do { stringList.Add(reader.ReadElementContentAsString("list", OpenEhrNamespace)); reader.MoveToContent(); } while (reader.LocalName == "list"); if (stringList.Count > 0) cString.List = new Set<string>(stringList); } if (reader.LocalName == "list_open") { cString.ListOpen = reader.ReadElementContentAsBoolean("list_open", OpenEhrNamespace); reader.MoveToContent(); cString.listOpenSet = true; } if (reader.LocalName == "assumed_value") { cString.AssumedValue = reader.ReadElementContentAsString("assumed_value", OpenEhrNamespace); reader.MoveToContent(); } reader.ReadEndElement(); reader.MoveToContent(); }