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


C# ModelElement.AddException方法代码示例

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


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

示例1: 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

示例2: Statement

        /// <summary>
        ///     Provides the parse tree according to the statement provided
        /// </summary>
        /// <param name="root">the element for which this statemennt should be parsed</param>
        /// <param name="expression"></param>
        /// <param name="silent">Indicates whether errors should be reported (silent == false) or not</param>
        /// <returns></returns>
        public Statement.Statement Statement(ModelElement root, string expression, bool silent = false)
        {
            Statement.Statement retVal = null;

            Util.DontNotify(() =>
            {
                // ReSharper disable once ConvertToLambdaExpression
                ModelElement.DontRaiseError(() =>
                {
                    try
                    {
                        Root = root;
                        Buffer = expression.ToCharArray();
                        retVal = Statement(root);

                        SkipWhiteSpaces();
                        if (Index != Buffer.Length)
                        {
                            if (Index < Buffer.Length)
                            {
                                throw new ParseErrorException("End of statement expected", Index, Buffer);
                            }
                        }

                        if (retVal != null)
                        {
                            retVal.SemanticAnalysis();
                        }
                    }
                    catch (Exception exception)
                    {
                        root.AddException(exception);
                    }
                });
            });

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


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