Ejemplo n.º 1
0
 protected void Validate(CDuration cDuration)
 {
     Invariant(cDuration.Range != null ||(cDuration.YearsAllowed || cDuration.MonthsAllowed || cDuration.WeeksAllowed
         || cDuration.DaysAllowed || cDuration.HoursAllowed || cDuration.MinutesAllowed || cDuration.SecondsAllowed ||
         cDuration.FractionalSecondsAllowed), "cDuration range is null, implies years_allowed or months_allowed or "+
         "weeks_allowed or days_allowed or hours_allowed or minutes_allowed or "+
         "seconds_allowed or fractional_seconds_allowed");
 }
Ejemplo n.º 2
0
        private void WriteXml(CDuration cPrimitive)
        {
            string OpenEhrNamespace = RmXmlSerializer.OpenEhrNamespace;
            string openEhrPrefix = RmXmlSerializer.UseOpenEhrPrefix(writer);

            if (!string.IsNullOrEmpty(cPrimitive.Pattern))
                writer.WriteElementString("pattern", OpenEhrNamespace, cPrimitive.Pattern);

            if (cPrimitive.Range != null)
            {
                writer.WriteStartElement(openEhrPrefix, "range", OpenEhrNamespace);
                this.WriteXml(cPrimitive.Range);
                writer.WriteEndElement();
            }

            if (cPrimitive.AssumedValue != null)
            {
                writer.WriteStartElement(openEhrPrefix, "assumed_value", OpenEhrNamespace);
                writer.WriteString(cPrimitive.AssumedValue.ToString());
                writer.WriteEndElement();
            }
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        private void ReadXml(CDuration cDuration)
        {
            if (reader.IsEmptyElement)
            {
                cDuration.AllowAny();
                reader.Skip();
            }
            else
            {
                reader.ReadStartElement();
                reader.MoveToContent();

                string openEhrNamespace = RmXmlSerializer.OpenEhrNamespace;

                if (reader.LocalName == "pattern")
                {
                    cDuration.Pattern = reader.ReadElementContentAsString("pattern", openEhrNamespace);
                    reader.MoveToContent();
                }

                if (reader.LocalName == "range")
                {
                    cDuration.Range = new Interval<Iso8601Duration>();
                    this.ReadXml(cDuration.Range);
                }

                if (reader.LocalName == "assumed_value")
                {
                    cDuration.AssumedValue = new AssumedTypes.Iso8601Duration(reader.ReadElementContentAsString("assumed_value", openEhrNamespace));
                    reader.MoveToContent();
                }

                reader.ReadEndElement();
            }

            reader.MoveToContent();
        }