ASCU_ALL/MigraDoc.Rendering/Rendering.UnitTest/TestParagraphIterator.cs

48 lines
1.4 KiB
C#
Raw Normal View History

2020-09-04 12:49:15 +05:00
using MigraDoc.DocumentObjectModel;
#pragma warning disable 1591
namespace MigraDoc.Rendering.UnitTest
{
/// <summary>
/// Summary description for TestParagraphIterator.
/// </summary>
public class TestParagraphIterator
{
public TestParagraphIterator()
{ }
public static string GetIterators(Paragraph paragraph)
{
ParagraphIterator iter = new ParagraphIterator(paragraph.Elements);
iter = iter.GetFirstLeaf();
string retString = "";
while (iter != null)
{
retString += "[" + iter.Current.GetType().Name + ":]";
if (iter.Current is Text)
retString += ((Text)iter.Current).Content;
iter = iter.GetNextLeaf();
}
return retString;
}
public static string GetBackIterators(Paragraph paragraph)
{
ParagraphIterator iter = new ParagraphIterator(paragraph.Elements);
iter = iter.GetLastLeaf();
string retString = "";
while (iter != null)
{
retString += "[" + iter.Current.GetType().Name + ":]";
if (iter.Current is Text)
retString += ((Text)iter.Current).Content;
iter = iter.GetPreviousLeaf();
}
return retString;
}
}
}