本文整理匯總了C#中Text.Last方法的典型用法代碼示例。如果您正苦於以下問題:C# Text.Last方法的具體用法?C# Text.Last怎麽用?C# Text.Last使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Text
的用法示例。
在下文中一共展示了Text.Last方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Parse
public static Text Parse(TextReader reader)
{
var text = new Text();
var line = reader.ReadLine();
while(!string.IsNullOrEmpty(line))
{
var paragraph = new Paragraph();
text.Add(paragraph);
while (!string.IsNullOrEmpty(line))
{
var sentenceString = line;
var terminalPunctuationMark = line.GetFirstOrDefaultPunctuationMark(DefaultPunctuationMarks.TerminalPunctuationMarks);
if (terminalPunctuationMark.HasValue)
{
var index = line.IndexOfPunctuationMark(terminalPunctuationMark);
sentenceString = line.Substring(0, index).TrimStart(' ');
line = line.Remove(0, index + terminalPunctuationMark.StringValue.Length);
if(text.Count > 1)
{
var lastParagraph = text.Last(p => p.HasValue);
if (lastParagraph.Any())
{
var lastSentence = lastParagraph.Last();
if (lastSentence.IsNotFinished)
{
text.Remove(paragraph);
paragraph = lastParagraph;
lastSentence.Concat(sentenceString);
continue;
}
}
}
}
else
{
line = string.Empty;
}
var sentence = ParseSentenceString(sentenceString, terminalPunctuationMark);
paragraph.Add(sentence);
}
line = reader.ReadLine();
}
return text;
}