Esempio n. 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;
 }
Esempio n. 2
0
 internal FunctionCall(string functionName, string returnType, ExprItem[] arglist)
     : base("function")
 {
     this.functionName = functionName;
     this.returnType = returnType;
     this.argList = argList;
 }
Esempio n. 3
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="expresion">Root of expression tree.</param>
 public Assertion(ExprItem expresion)
 {
     this.Expression = expresion;
 }
Esempio n. 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;
 }
Esempio n. 5
0
 protected void ValidateBase(ExprItem exprItem)
 {
     Invariant(!string.IsNullOrEmpty(exprItem.Type), string.Format(
         CommonStrings.XMustNotBeNull, "ExprItem.Type"));
 }
Esempio n. 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);
            }
        }
Esempio n. 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;
 }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 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();
        }
Esempio n. 11
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="expresion">Root of expression tree.</param>
 public Assertion(ExprItem expresion)
 {
     this.Expression = expresion;
 }