本文整理汇总了C#中LineInfo.TrimRight方法的典型用法代码示例。如果您正苦于以下问题:C# LineInfo.TrimRight方法的具体用法?C# LineInfo.TrimRight怎么用?C# LineInfo.TrimRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LineInfo
的用法示例。
在下文中一共展示了LineInfo.TrimRight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsMultiLine
/// <summary>
/// Determines if this node spans over multiple lines.
/// </summary>
/// <param name="line">contains line information (and text)</param>
/// <param name="isContinued">true if the previous line was continued.</param>
/// <returns>true if this line continues onto the next.</returns>
public override bool IsMultiLine(LineInfo line, bool isContinued)
{
string trimmed = line.Data.TrimEnd();
if (trimmed.Length == 0)
return false;
if (trimmed.EndsWith("|"))
{
line.TrimRight(1);
return true;
}
return false;
}
示例2: IsMultiLine
/// <summary>
/// Determines if this node spans over multiple lines.
/// </summary>
/// <param name="line">contains line information (and text)</param>
/// <param name="isContinued">true if the previous line was continued.</param>
/// <returns>true if this line continues onto the next.</returns>
public override bool IsMultiLine(LineInfo line, bool isContinued)
{
// hack to dont include code
// a more proper way would have bene to scan after each tag
if (!isContinued)
{
char ch = line.Data[0];
if (ch != '#' && ch != '%' && ch != '.')
return false;
}
bool inQuote = false;
bool inAttribute = false;
if (isContinued && line.Data.IndexOf('{') == -1)
inAttribute = true;
foreach (char ch in line.Data)
{
if (ch == '"')
inQuote = !inQuote;
else if (ch == '{' && !inQuote)
{
if (inAttribute)
throw new CodeGeneratorException(line.LineNumber, line.Data,
"Found another start of attributes, but no close tag. Have you forgot one '}'?");
inAttribute = true;
}
else if (ch == '}' && !inQuote)
inAttribute = false;
}
if (inQuote)
throw new CodeGeneratorException(line.LineNumber, line.Data, "Attribute quotes can not span over multiple lines.");
if (inAttribute)
{
//todo: Attach a log writer.
//Console.WriteLine("Attribute is not closed, setting unfinished rule");
line.UnfinishedRule = this;
line.Data.TrimEnd();
if (line.Data.EndsWith("|"))
line.TrimRight(1);
return true;
}
return inAttribute;
}