本文整理汇总了C#中IMessageHandler.TemplateMessage方法的典型用法代码示例。如果您正苦于以下问题:C# IMessageHandler.TemplateMessage方法的具体用法?C# IMessageHandler.TemplateMessage怎么用?C# IMessageHandler.TemplateMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessageHandler
的用法示例。
在下文中一共展示了IMessageHandler.TemplateMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public List<AsbtractCodeFragment> Parse(FileLine line, IMessageHandler messageHandler)
{
List<AsbtractCodeFragment> fragments = new List<AsbtractCodeFragment>();
var beginIndexIndent = (line.BeginIndexNonSpace + 1); //skip matched character
var index = line.Text.IndexOfNot(beginIndexIndent, line.EndIndex, CharExtensions.IsSpace);
if (index == -1) {
index = line.EndIndex;
}
fragments.Add(new TargetIndentation(line, new TextSpan(beginIndexIndent, index, line.Text)));
var endIndex = index;
while (index < line.EndIndex) {
index = line.Text.IndexOf(index, line.EndIndex, (ch) => ch == '#');
if (index == -1) { // reached line end
break;
}
var expressionBeginIndex = index + 1; //skip #
if (expressionBeginIndex == line.EndIndex) { // reached line end
break;
}
switch (line.Text[expressionBeginIndex]) {
case '#':
fragments.Add(new OriginText(line, new TextSpan(expressionBeginIndex, expressionBeginIndex + 1, line.Text)));
index = endIndex = expressionBeginIndex + 1;
continue;
case '{':
var expressionEndIndex = BraceCounter.MatchBraces(expressionBeginIndex, line.EndIndex, line.Text);
if (expressionEndIndex == -1) {
endIndex = line.EndIndex;
messageHandler.TemplateMessage(TraceLevel.Error, line.Position, "Missing a closing '}'.");
break;
}
fragments.Add(new OriginExpression(line, new TextSpan(expressionBeginIndex + 1, expressionEndIndex - 1, line.Text)));
index = endIndex = expressionEndIndex + 1;
continue;
default:
index = endIndex = expressionBeginIndex + 1;
continue;
}
}
fragments.Add(new OriginText(line, new TextSpan(endIndex, line.EndIndex, line.Text)));
return fragments;
}