Beispiel #1
0
        protected void Validate(ExprUnaryOperator unaryOperator)
        {
            this.ValidateBase((ExprOperator)unaryOperator);

            Invariant(unaryOperator.Operand != null,
                string.Format(CommonStrings.XMustNotBeNull, "unaryOperator.Operand"));
            this.Validate(unaryOperator.Operand);
        }
Beispiel #2
0
        private void ReadXml(ExprUnaryOperator exprUnaryOperator)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            this.ReadXmlBase((ExprOperator)exprUnaryOperator);

            if (reader.LocalName != "operand")
                throw new InvalidXmlException("operand" + reader.LocalName);
            string operandType = reader.GetAttribute("type", XsiNamespace);
            Check.Assert(!string.IsNullOrEmpty(operandType), "operandType must not be null or empty.");
            exprUnaryOperator.Operand = AmFactory.ExprItem(operandType);
            this.ReadXml(exprUnaryOperator.Operand);

            if (reader.LocalName != "precedence_overridden")
                throw new InvalidXmlException("precedence_overridden" + reader.LocalName);
            exprUnaryOperator.PrecedenceOverriden = reader.ReadElementContentAsBoolean("precedence_overridden", OpenEhrNamespace);

            DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement,
              "Expected endElement of AssertionVairable");
            reader.ReadEndElement();
            reader.MoveToContent();
        }
Beispiel #3
0
        internal static ExprItem ExprItem(string typeName)
        {
            DesignByContract.Check.Require(!string.IsNullOrEmpty(typeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "typeName"));

            ExprItem exprItem = null;
            switch (typeName)
            {
                case "EXPR_LEAF":
                    exprItem = new ExprLeaf();
                    break;
                case "EXPR_UNARY_OPERATOR":
                    exprItem = new ExprUnaryOperator();
                    break;
                case "EXPR_BINARY_OPERATOR":
                    exprItem = new ExprBinaryOperator();
                    break;
                default:
                    throw new NotSupportedException("type not supported: " + typeName);
            }

            DesignByContract.Check.Ensure(exprItem != null, "exprItem must not be null.");

            return exprItem;
        }
Beispiel #4
0
        private void WriteXml(ExprUnaryOperator exprUnaryOperator)
        {
            Check.Require(exprUnaryOperator != null, string.Format(CommonStrings.XMustNotBeNull, "exprUnaryOperator"));
            Check.Require(exprUnaryOperator.Operand != null, string.Format(CommonStrings.XMustNotBeNull, "exprUnaryOperator.Operand"));

            this.WriteXml((ExprOperator)exprUnaryOperator);

            writer.WriteStartElement(UseOpenEhrPrefix(writer), "operand", OpenEhrNamespace);
            string operandType = AmType.GetName(exprUnaryOperator.Operand);
            writer.WriteAttributeString(UseXsiPrefix(writer), "type", XsiNamespace, operandType);

            this.WriteXml(exprUnaryOperator.Operand);
            writer.WriteEndElement();
        }