Esempio n. 1
0
 protected void Validate(AssertionVariable assertionVariable)
 {
     Invariant(!string.IsNullOrEmpty(assertionVariable.Name), string.Format(
         CommonStrings.XMustNotBeNull, "AssertionVariable.Name"));
     Invariant(!string.IsNullOrEmpty(assertionVariable.Definition), string.Format(
         CommonStrings.XMustNotBeNull, "AssertionVariable.Definition"));
 }
Esempio n. 2
0
        private void ReadXml(Assertion assertion)
        {
            Check.Require(assertion!=null, "assertion must not be null.");

            reader.ReadStartElement();
            reader.MoveToContent();

            if (reader.LocalName == "tag")
            {
                assertion.Tag = reader.ReadElementContentAsString("tag", OpenEhrNamespace);
                reader.MoveToContent();
            }

            if (reader.LocalName == "string_expression")
            {
                assertion.StringExpression = reader.ReadElementContentAsString("string_expression", OpenEhrNamespace);
                reader.MoveToContent();

            }

            if (reader.LocalName != "expression")
                throw new InvalidXmlException("expression" + reader.LocalName);
            string expressionType = reader.GetAttribute("type", XsiNamespace);
            ExprItem expression = AmFactory.ExprItem(expressionType);
            this.ReadXml(expression);
            assertion.Expression = expression;

            if (reader.LocalName == "variables")
            {
                assertion.Variables = new OpenEhr.AssumedTypes.List<AssertionVariable>();
                do
                {
                    AssertionVariable variable = new AssertionVariable();
                    this.ReadXml(variable);

                    assertion.Variables.Add(variable);
                } while (reader.LocalName == "variables");

                DesignByContract.Check.Assert(assertion.Variables.Count > 0, "variableList must not be empty.");
            }

            DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement,
              "Expected endElement of Assertion");
            reader.ReadEndElement();
            reader.MoveToContent();
        }
Esempio n. 3
0
        private void ReadXml(AssertionVariable assertionVariable)
        {
            Check.Require(assertionVariable != null, "assertionVariable must not be null.");

            reader.ReadStartElement();
            reader.MoveToContent();

            if (reader.LocalName != "name")
                throw new InvalidXmlException("name" + reader.LocalName);
            assertionVariable.Name = reader.ReadElementContentAsString("name", OpenEhrNamespace);
            reader.MoveToContent();

            if (reader.LocalName != "definition")
                throw new InvalidXmlException("definition" + reader.LocalName);
            assertionVariable.Definition = reader.ReadElementContentAsString("definition", OpenEhrNamespace);
            reader.MoveToContent();

            DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement,
              "Expected endElement of AssertionVairable");
            reader.ReadEndElement();
            reader.MoveToContent();
        }
Esempio n. 4
0
        private void WriteXml(AssertionVariable assertionVariable)
        {
            Check.Require(assertionVariable != null, string.Format(CommonStrings.XMustNotBeNull, "assertionVariable"));
            Check.Require(!string.IsNullOrEmpty(assertionVariable.Name), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "assertionVariable.Name"));
            Check.Require(!string.IsNullOrEmpty(assertionVariable.Definition), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "assertionVariable.Definition"));

            writer.WriteElementString(UseOpenEhrPrefix(writer), "name", OpenEhrNamespace, assertionVariable.Name);
            writer.WriteElementString(UseOpenEhrPrefix(writer), "definition", OpenEhrNamespace, assertionVariable.Definition);
        }