本文整理汇总了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;
}
示例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;
}