当前位置: 首页>>代码示例>>C#>>正文


C# ModelElement.AddError方法代码示例

本文整理汇总了C#中ModelElement.AddError方法的典型用法代码示例。如果您正苦于以下问题:C# ModelElement.AddError方法的具体用法?C# ModelElement.AddError怎么用?C# ModelElement.AddError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelElement的用法示例。


在下文中一共展示了ModelElement.AddError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: additionalChecks

        /// <summary>
        /// Perform additional checks based on the parameter types
        /// </summary>
        /// <param name="root">The element on which the errors should be reported</param>
        /// <param name="context">The evaluation context</param>
        /// <param name="actualParameters">The parameters applied to this function call</param>
        public override void additionalChecks(ModelElement root, Interpreter.InterpretationContext context, Dictionary<string, Interpreter.Expression> actualParameters)
        {
            CheckFunctionalParameter(root, context, actualParameters[First.Name], 1);
            CheckFunctionalParameter(root, context, actualParameters[Second.Name], 1);

            Function function1 = actualParameters[First.Name].GetExpressionType() as Function;
            Function function2 = actualParameters[Second.Name].GetExpressionType() as Function;

            if (function1 != null && function2 != null)
            {
                if (function1.FormalParameters.Count == 1 && function2.FormalParameters.Count == 1)
                {
                    Parameter p1 = (Parameter)function1.FormalParameters[0];
                    Parameter p2 = (Parameter)function2.FormalParameters[0];

                    if (p1.Type != p2.Type && p1.Type != EFSSystem.DoubleType && p2.Type != EFSSystem.DoubleType)
                    {
                        root.AddError("The formal parameters for the functions provided as parameter are not the same");
                    }
                }

                if (function1.ReturnType != function2.ReturnType && function1.ReturnType != EFSSystem.DoubleType && function2.ReturnType != EFSSystem.DoubleType)
                {
                    root.AddError("The return values for the functions provided as parameter are not the same");
                }
            }
        }
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:33,代码来源:Max.cs

示例2: CheckFunctionalParameter

        /// <summary>
        /// Ensures that the parameter provided corresponds to a function double->double
        /// </summary>
        /// <param name="root">Element on which the errors shall be attached</param>
        /// <param name="context">The context used to evaluate the expression</param>
        /// <param name="expression">The expression which references the function</param>
        /// <param name="count">the expected number of parameters</param>
        protected virtual void CheckFunctionalParameter(ModelElement root, Interpreter.InterpretationContext context, Interpreter.Expression expression, int count)
        {
            Types.Type type = expression.GetExpressionType();

            Function function = type as Function;
            if (function != null)
            {
                if (function.FormalParameters.Count == count)
                {
                    foreach (Parameter parameter in function.FormalParameters)
                    {
                        if (!parameter.Type.IsDouble())
                        {
                            root.AddError(expression.ToString() + " does not takes a double for parameter " + parameter.Name);
                        }
                    }
                }
                else
                {
                    root.AddError(expression.ToString() + " does not take " + count + "parameter(s) as input");
                }

                if (!function.ReturnType.IsDouble())
                {
                    root.AddError(expression.ToString() + " does not return a double");
                }
            }
            else
            {
                if (!type.IsDouble())
                {
                    root.AddError(expression.ToString() + " type is not double");
                }
            }
        }
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:42,代码来源:PredefinedFunction.cs

示例3: CheckChanges

 /// <summary>
 ///     Ensures that all changes have a correct value
 /// </summary>
 /// <param name="element"></param>
 public void CheckChanges(ModelElement element)
 {
     foreach (Change change in Changes)
     {
         if (change.NewValue == null)
         {
             element.AddError(change.Variable.FullName + " <- <cannot evaluate value>");
         }
     }
 }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:14,代码来源:Change.cs

示例4: Expression

        /// <summary>
        ///     Provides the parse tree according to the expression provided
        /// </summary>
        /// <param name="root">the element for which this expression should be parsed</param>
        /// <param name="expression">the expression to parse</param>
        /// <param name="filter">The filter to apply when performing the semantic analysis</param>
        /// <param name="doSemanticalAnalysis">true indicates that the semantical analysis should be performed</param>
        /// <param name="log">the element on which errors should be raised. By default, this is root</param>
        /// <param name="silent">Indicates whether errors should be reported (silent = false) or not</param>
        /// <returns></returns>
        public Expression Expression(ModelElement root, string expression, BaseFilter filter = null,
            bool doSemanticalAnalysis = true, ModelElement log = null, bool silent = false)
        {
            Expression retVal = null;

            NoReentrance.WaitOne();
            ModelElement.DontRaiseError(silent, () =>
            {
                try
                {
                    // Setup context
                    Root = root;
                    RootLog = log;
                    if (RootLog == null)
                    {
                        RootLog = Root;
                    }

                    Buffer = expression.ToCharArray();
                    retVal = Expression(0);

                    SkipWhiteSpaces();
                    if (Index != Buffer.Length)
                    {
                        retVal = null;
                        if (Index < Buffer.Length)
                        {
                            RootLog.AddError("End of expression expected, but found " + Buffer[Index]);
                        }
                        else
                        {
                            RootLog.AddError("End of expression expected, but found EOF");
                        }
                    }
                    if (retVal != null && doSemanticalAnalysis)
                    {
                        if (filter == null)
                        {
                            retVal.SemanticAnalysis(IsVariableOrValue.INSTANCE);
                        }
                        else
                        {
                            retVal.SemanticAnalysis(filter);
                        }
                    }
                }
                catch (Exception e)
                {
                    root.AddException(e);
                }
                finally
                {
                    NoReentrance.ReleaseMutex();
                }
            });

            return retVal;
        }
开发者ID:nikiforovandrey,项目名称:ERTMSFormalSpecs,代码行数:68,代码来源:Parser.cs

示例5: additionalChecks

        /// <summary>
        /// Perform additional checks based on the parameter types
        /// </summary>
        /// <param name="root">The element on which the errors should be reported</param>
        /// <param name="context">The evaluation context</param>
        /// <param name="actualParameters">The parameters applied to this function call</param>
        public override void additionalChecks(ModelElement root, Interpreter.InterpretationContext context, Dictionary<string, Interpreter.Expression> actualParameters)
        {
            CheckFunctionalParameter(root, context, actualParameters[Targets1.Name], 1);
            CheckFunctionalParameter(root, context, actualParameters[Targets2.Name], 1);
            CheckFunctionalParameter(root, context, actualParameters[Targets3.Name], 1);

            Function function1 = actualParameters[Targets1.Name].GetExpressionType() as Function;
            Function function2 = actualParameters[Targets2.Name].GetExpressionType() as Function;
            Function function3 = actualParameters[Targets3.Name].GetExpressionType() as Function;

            if (function1 != null && function2 != null && function3 != null)
            {
                if (function1.ReturnType != function2.ReturnType || function2.ReturnType != function3.ReturnType)
                {
                    root.AddError("The types of functions provided are not the same");
                }
            }
        }
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:24,代码来源:Targets.cs

示例6: Expression

        /// <summary>
        /// Provides the parse tree according to the expression provided
        /// </summary>
        /// <param name="root">the element for which this expression should be parsed</param>
        /// <param name="expression"></param>
        /// <returns></returns>
        public Expression Expression(ModelElement root, string expression)
        {
            Expression retVal = null;

            try
            {
                Generated.ControllersManager.NamableController.DesactivateNotification();
                Root = root;
                Buffer = expression.ToCharArray();
                retVal = Expression(0);

                skipWhiteSpaces();
                if (Index != Buffer.Length)
                {
                    retVal = null;
                    if (Index < Buffer.Length)
                    {
                        Root.AddError("End of expression expected, but found " + Buffer[Index]);
                    }
                    else
                    {
                        Root.AddError("End of expression expected, but found EOF");
                    }
                }
                if (retVal != null)
                {
                    retVal.SemanticAnalysis(Filter.IsVariableOrValue);
                }
            }
            finally
            {
                Generated.ControllersManager.NamableController.ActivateNotification();
            }

            return retVal;
        }
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:42,代码来源:Parser.cs

示例7: Statement

        /// <summary>
        /// Provides the Term at position Index of the Buffer.        
        /// </summary>
        /// <param name="root">The root element for which this term is built</param>
        /// <returns></returns>
        private Statement.Statement Statement(ModelElement root)
        {
            Statement.Statement retVal = null;

            Root = root;
            if (LookAhead("APPLY"))
            {
                Match("APPLY");
                Call callExpression = Expression(0) as Call;
                if (callExpression != null)
                {
                    Statement.ProcedureCallStatement call = new Statement.ProcedureCallStatement(root, callExpression);
                    Match("ON");
                    Expression listExpression = Expression(0);
                    Expression condition = null;
                    if (LookAhead("|"))
                    {
                        Match("|");
                        condition = Expression(0);
                    }
                    retVal = new Statement.ApplyStatement(root, call, listExpression, condition);
                }
                else
                {
                    Root.AddError("Cannot parse call expression");
                }
            }
            else if (LookAhead("INSERT"))
            {
                Match("INSERT");
                Expression value = Expression(0);
                if (value != null)
                {
                    Match("IN");
                    Expression list = Expression(0);
                    Expression replaceElement = null;
                    if (LookAhead("WHEN"))
                    {
                        Match("WHEN");
                        Match("FULL");
                        Match("REPLACE");

                        replaceElement = Expression(0);
                    }
                    retVal = new Statement.InsertStatement(root, value, list, replaceElement);
                }
            }
            else if (LookAhead("REMOVE"))
            {
                Match("REMOVE");

                Statement.RemoveStatement.PositionEnum position = Interpreter.Statement.RemoveStatement.PositionEnum.First;
                if (LookAhead("FIRST"))
                {
                    Match("FIRST");
                }
                else if (LookAhead("LAST"))
                {
                    Match("LAST");
                    position = Interpreter.Statement.RemoveStatement.PositionEnum.Last;
                }
                else if (LookAhead("ALL"))
                {
                    Match("ALL");
                    position = Interpreter.Statement.RemoveStatement.PositionEnum.All;
                }

                Expression condition = null;
                if (!LookAhead("IN"))
                {
                    condition = Expression(0);
                }
                Match("IN");
                Expression list = Expression(0);
                retVal = new Statement.RemoveStatement(root, condition, position, list);
            }
            else if (LookAhead("REPLACE"))
            {
                Match("REPLACE");
                Expression condition = Expression(0);
                Match("IN");
                Expression list = Expression(0);
                Match("BY");
                Expression value = Expression(0);

                retVal = new Statement.ReplaceStatement(root, value, list, condition);
            }
            else
            {
                Expression expression = Expression(0);
                if (expression != null)
                {
                    if (LookAhead("<-"))
                    {
                        // This is a variable update
//.........这里部分代码省略.........
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:101,代码来源:Parser.cs

示例8: CheckChange

        /// <summary>
        /// Checks that the change is valid
        /// </summary>
        /// <param name="element"></param>
        public override bool CheckChange(ModelElement element)
        {
            bool retVal = true;

            if (Variable == null)
            {
                element.AddError("Cannot determine variable to be updated");
                retVal = false;
            }

            return retVal;
        }
开发者ID:ERTMSSolutions,项目名称:ERTMSFormalSpecs,代码行数:16,代码来源:InsertInListChange.cs


注:本文中的ModelElement.AddError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。