Beispiel #1
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="leftOperand">Left operand node.</param>
 /// <param name="rightOperand">Right operand node.</param>
 /// <param name="type">Type name of this item in the mathematical sense.</param>
 /// <param name="anOperator">Code of operator.</param>
 /// <param name="precedenceOverriden">True if the natural precedence of operators is
 /// overridden in the expression represented by this node of the expression tree.</param>
 public ExprBinaryOperator(ExprItem leftOperand, ExprItem rightOperand, string type,
                           OperatorKind anOperator, bool precedenceOverriden)
     : base(type, anOperator, precedenceOverriden)
 {
     this.LeftOperand  = leftOperand;
     this.RightOperand = rightOperand;
 }
Beispiel #2
0
 internal FunctionCall(string functionName, string returnType, ExprItem[] arglist)
     : base("function")
 {
     this.functionName = functionName;
     this.returnType = returnType;
     this.argList = argList;
 }
Beispiel #3
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="expresion">Root of expression tree.</param>
 public Assertion(ExprItem expresion)
 {
     this.Expression = expresion;
 }
Beispiel #4
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="operand"> Operand node.</param>
 /// <param name="type">Type name of this item in the mathematical sense.</param>
 /// <param name="anOperator">Code of operator.</param>
 /// <param name="precedenceOverriden">True if the natural precedence of operators is 
 /// overridden in the expression represented by this node of the expression tree.</param>
 public ExprUnaryOperator(ExprItem operand, string type, OperatorKind anOperator, bool precedenceOverriden)
     : base(type, anOperator, precedenceOverriden)
 {
     this.Operand = operand;
 }
Beispiel #5
0
 protected void ValidateBase(ExprItem exprItem)
 {
     Invariant(!string.IsNullOrEmpty(exprItem.Type), string.Format(
         CommonStrings.XMustNotBeNull, "ExprItem.Type"));
 }
Beispiel #6
0
        protected void Validate(ExprItem exprItem)
        {
            if (exprItem == null) throw new ArgumentNullException(string.Format(
                CommonStrings.XMustNotBeNull, "exprItem"));

            const string methodName = "Validate";

            try
            {
                System.Reflection.MethodInfo method = this.GetType().GetMethod(methodName,
                    System.Reflection.BindingFlags.ExactBinding | System.Reflection.BindingFlags.NonPublic
                    | System.Reflection.BindingFlags.Instance, Type.DefaultBinder,
                               new Type[] { exprItem.GetType() },
                               new System.Reflection.ParameterModifier[0]);

                if (method != null)
                {
                    if (method != lastExprItemMethodRead || exprItem != lastExprItem)
                    {
                        lastExprItemMethodRead = method;
                        lastExprItem = exprItem;

                        method.Invoke(this, new Object[] { exprItem });

                    }
                    else
                    {
                        string message = string.Format(CommonStrings.LoopingMethodTerminated,
                            methodName, exprItem.GetType().ToString());
                        System.Diagnostics.Debug.WriteLine(message);
                        throw new ApplicationException(message);
                    }
                }
                else
                {
                    string message = string.Format(CommonStrings.MethodXNotImplementedForParamTypeY,
                        methodName, exprItem.GetType().ToString());
                    System.Diagnostics.Debug.WriteLine(message);
                    throw new ApplicationException(message);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                    if (ex.InnerException is ApplicationException && ex.InnerException.InnerException != null
                            && ex.InnerException.Message == ex.InnerException.InnerException.Message)
                        throw new ApplicationException(ex.InnerException.Message, ex.InnerException.InnerException);
                    else
                        throw new ApplicationException(ex.InnerException.Message, ex.InnerException);
                else
                    throw new ApplicationException(ex.Message, ex);
            }
        }
Beispiel #7
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="operand"> Operand node.</param>
 /// <param name="type">Type name of this item in the mathematical sense.</param>
 /// <param name="anOperator">Code of operator.</param>
 /// <param name="precedenceOverriden">True if the natural precedence of operators is
 /// overridden in the expression represented by this node of the expression tree.</param>
 public ExprUnaryOperator(ExprItem operand, string type, OperatorKind anOperator, bool precedenceOverriden)
     :
     base(type, anOperator, precedenceOverriden)
 {
     this.Operand = operand;
 }
Beispiel #8
0
        private void WriteXmlBase(ExprItem exprItem)
        {
            Check.Require(exprItem != null, string.Format(CommonStrings.XMustNotBeNull, "exprItem"));
            Check.Require(!string.IsNullOrEmpty(exprItem.Type), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "exprItem.Type"));

            writer.WriteElementString(UseOpenEhrPrefix(writer), "type", OpenEhrNamespace, exprItem.Type);
        }
Beispiel #9
0
        private void WriteXml(ExprItem exprItem)
        {
            if (exprItem == null) throw new ArgumentNullException(string.Format(CommonStrings.XIsNull, "exprItem"));

            const string methodName = "WriteXml";

            try
            {
                System.Reflection.MethodInfo method = this.GetType().GetMethod(methodName,
                    System.Reflection.BindingFlags.ExactBinding | System.Reflection.BindingFlags.NonPublic
                    | System.Reflection.BindingFlags.Instance, Type.DefaultBinder,
                               new Type[] { exprItem.GetType() },
                               new System.Reflection.ParameterModifier[0]);

                if (method != null)
                {
                    // Avoid StackOverflow exceptions by executing only if the method and visitable
                    // are different from the last parameters used.
                    if (method != lastMethodWriteXmlExprItem || exprItem != lastExprItemWrite)
                    {
                        lastMethodWriteXmlExprItem = method;
                        lastExprItemWrite = exprItem;

                        method.Invoke(this, new Object[] { exprItem });

                    }
                    else
                    {
                        string message = string.Format(CommonStrings.LoopingMethodTerminated,
                            methodName, exprItem.GetType().ToString());
                        System.Diagnostics.Debug.WriteLine(message);
                        throw new ApplicationException(message);
                    }
                }
                else
                {
                    string message = string.Format(CommonStrings.MethodXNotImplementedForParamTypeY,
                            methodName, exprItem.GetType().ToString());
                    System.Diagnostics.Debug.WriteLine(message);
                    throw new ApplicationException(message);
                }
            }
            catch (System.Reflection.TargetInvocationException ex)
            {
                if (ex.InnerException != null)
                    throw new ApplicationException(ex.InnerException.Message, ex.InnerException);
                else
                    throw new ApplicationException(ex.Message, ex);
            }
        }
Beispiel #10
0
        private void ReadXmlBase(ExprItem exprItem)
        {
            Check.Require(exprItem != null, "exprItem must not be null.");

            if (reader.LocalName != "type")
                throw new InvalidXmlException("type", reader.LocalName);
            exprItem.Type = reader.ReadElementContentAsString("type", OpenEhrNamespace);
            reader.MoveToContent();
        }
Beispiel #11
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="expresion">Root of expression tree.</param>
 public Assertion(ExprItem expresion)
 {
     this.Expression = expresion;
 }