Class DocumentVisitor
Названий на: Aspose.Note Асамблея: Aspose.Note.dll (25.4.0)
Абстрактний клас для ітеріації через підводне дерево з корінням на зазначеному вузлі.
public abstract class DocumentVisitor
Inheritance
Нападні члени
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Показує, як отримати доступ до контенту документа за допомогою відвідувача.
public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Open the document we want to convert.
Document doc = new Document(dataDir + "Aspose.one");
// Create an object that inherits from the DocumentVisitor class.
MyOneNoteToTxtWriter myConverter = new MyOneNoteToTxtWriter();
// This is the well known Visitor pattern. Get the model to accept a visitor.
// The model will iterate through itself by calling the corresponding methods
// on the visitor object (this is called visiting).
//
// Note that every node in the object model has the Accept method so the visiting
// can be executed not only for the whole document, but for any node in the document.
doc.Accept(myConverter);
// Once the visiting is complete, we can retrieve the result of the operation,
// that in this example, has accumulated in the visitor.
Console.WriteLine(myConverter.GetText());
Console.WriteLine(myConverter.NodeCount);
}
/// <summary>
/// Simple implementation of saving a document in the plain text format. Implemented as a Visitor.
/// </summary>
public class MyOneNoteToTxtWriter : DocumentVisitor
{
public MyOneNoteToTxtWriter()
{
nodecount = 0;
mIsSkipText = false;
mBuilder = new StringBuilder();
}
/// <summary>
/// Gets the plain text of the document that was accumulated by the visitor.
/// </summary>
public string GetText()
{
return mBuilder.ToString();
}
/// <summary>
/// Adds text to the current output. Honors the enabled/disabled output flag.
/// </summary>
private void AppendText(string text)
{
if (!mIsSkipText)
{
mBuilder.AppendLine(text);
}
}
/// <summary>
/// Called when a RichText node is encountered in the document.
/// </summary>
public override void VisitRichTextStart(RichText run)
{
++nodecount;
AppendText(run.Text);
}
/// <summary>
/// Called when a Document node is encountered in the document.
/// </summary>
public override void VisitDocumentStart(Document document)
{
++nodecount;
}
/// <summary>
/// Called when a Page node is encountered in the document.
/// </summary>
public override void VisitPageStart(Page page)
{
++nodecount;
this.AppendText($"*** Page '{page.Title?.TitleText?.Text ?? "(no title)"}' ***");
}
/// <summary>
/// Called when processing of a Page node is finished.
/// </summary>
public override void VisitPageEnd(Page page)
{
this.AppendText(string.Empty);
}
/// <summary>
/// Called when a Title node is encountered in the document.
/// </summary>
public override void VisitTitleStart(Title title)
{
++nodecount;
}
/// <summary>
/// Called when a Image node is encountered in the document.
/// </summary>
public override void VisitImageStart(Image image)
{
++nodecount;
}
/// <summary>
/// Called when a OutlineGroup node is encountered in the document.
/// </summary>
public override void VisitOutlineGroupStart(OutlineGroup outlineGroup)
{
++nodecount;
}
/// <summary>
/// Called when a Outline node is encountered in the document.
/// </summary>
public override void VisitOutlineStart(Outline outline)
{
++nodecount;
}
/// <summary>
/// Called when a OutlineElement node is encountered in the document.
/// </summary>
public override void VisitOutlineElementStart(OutlineElement outlineElement)
{
++nodecount;
}
/// <summary>
/// Gets the total count of nodes by the Visitor
/// </summary>
public Int32 NodeCount
{
get { return this.nodecount; }
}
private readonly StringBuilder mBuilder;
private bool mIsSkipText;
private Int32 nodecount;
}
Constructors
DocumentVisitor()
protected DocumentVisitor()
Methods
VisitAttachedFileEnd(AttachedFile)
Закінчитися, щоб відвідати Aspose.Note.AttachedFile нод.
public virtual void VisitAttachedFileEnd(AttachedFile attachedFile)
Parameters
attachedFile
AttachedFile
Про це йдеться в повідомленні Aspose.Note.AttachedFile nod.
VisitAttachedFileStart(AttachedFile)
Почніть відвідувати нод Aspose.Note.AttachedFile.
public virtual void VisitAttachedFileStart(AttachedFile attachedFile)
Parameters
attachedFile
AttachedFile
Про це йдеться в повідомленні Aspose.Note.AttachedFile nod.
VisitDocumentEnd(Document)
Завершиться, щоб відвідати Aspose.Note.Документальний вузол.
public virtual void VisitDocumentEnd(Document document)
Parameters
document
Document
Про це йдеться в повідомленні Aspose.Note.Document node.
VisitDocumentStart(Document)
Почніть відвідувати Aspose.Note.Document node.
public virtual void VisitDocumentStart(Document document)
Parameters
document
Document
Про це йдеться в повідомленні Aspose.Note.Document node.
VisitImageEnd(Image)
Закінчити, щоб відвідати Aspose.Note.Image node.
public virtual void VisitImageEnd(Image image)
Parameters
image
Image
Історія Aspose.Note. зображення нод.
VisitImageStart(Image)
Почніть відвідувати Aspose.Note.Image node.
public virtual void VisitImageStart(Image image)
Parameters
image
Image
Історія Aspose.Note. зображення нод.
VisitInkDrawingEnd(InkDrawing)
Закінчитися, щоб відвідати Aspose.Note.InkDrawing нод.
public virtual void VisitInkDrawingEnd(InkDrawing inkDrawing)
Parameters
inkDrawing
InkDrawing
Про це йдеться в повідомленні Aspose.Note.InkDrawing node.
VisitInkDrawingStart(InkDrawing)
Почніть відвідувати нод Aspose.Note.InkDrawing.
public virtual void VisitInkDrawingStart(InkDrawing inkDrawing)
Parameters
inkDrawing
InkDrawing
Про це йдеться в повідомленні Aspose.Note.InkDrawing node.
VisitInkParagraphEnd(InkParagraph)
Завершиться, щоб відвідати Aspose.Note.InkParagraph нод.
public virtual void VisitInkParagraphEnd(InkParagraph inkParagraph)
Parameters
inkParagraph
InkParagraph
Про це йдеться в повідомленні Aspose.Note.InkParagraph node.
VisitInkParagraphStart(InkParagraph)
Почніть відвідувати нод Aspose.Note.InkParagraph.
public virtual void VisitInkParagraphStart(InkParagraph inkParagraph)
Parameters
inkParagraph
InkParagraph
Про це йдеться в повідомленні Aspose.Note.InkParagraph node.
VisitInkWordEnd(InkWord)
Закінчити, щоб відвідати Aspose.Note.InkWord вузол.
public virtual void VisitInkWordEnd(InkWord inkWord)
Parameters
inkWord
InkWord
Про це йдеться в повідомленні Aspose.Note.InkWord.
VisitInkWordStart(InkWord)
Почніть відвідувати нод Aspose.Note.InkWord.
public virtual void VisitInkWordStart(InkWord inkWord)
Parameters
inkWord
InkWord
Про це йдеться в повідомленні Aspose.Note.InkWord.
VisitLoopEnd(Loop)
Закінчити, щоб відвідати Aspose.Note.Loop нод.
public virtual void VisitLoopEnd(Loop loop)
Parameters
loop
Loop
Про це йдеться в повідомленні Aspose.Note.Loop node.
VisitLoopStart(Loop)
Почніть відвідувати Aspose.Note.Loop нод.
public virtual void VisitLoopStart(Loop loop)
Parameters
loop
Loop
Про це йдеться в повідомленні Aspose.Note.Loop node.
VisitOutlineElementEnd(OutlineElement)
Завершиться, щоб відвідати Aspose.Note.OutlineЕлемент нід.
public virtual void VisitOutlineElementEnd(OutlineElement outlineElement)
Parameters
outlineElement
OutlineElement
Про це йдеться в повідомленні Aspose.Note.OutlineElement.
VisitOutlineElementStart(OutlineElement)
Почніть відвідувати нод Aspose.Note.OutlineElement.
public virtual void VisitOutlineElementStart(OutlineElement outlineElement)
Parameters
outlineElement
OutlineElement
Про це йдеться в повідомленні Aspose.Note.OutlineElement.
VisitOutlineEnd(Outline)
Закінчити, щоб відвідати Aspose.Note.Outline нод.
public virtual void VisitOutlineEnd(Outline outline)
Parameters
outline
Outline
Про це йдеться в повідомленні Aspose.Note.Outline node.
VisitOutlineGroupEnd(OutlineGroup)
Завершиться, щоб відвідати Aspose.Note.OutlineGroup нод.
public virtual void VisitOutlineGroupEnd(OutlineGroup outlineGroup)
Parameters
outlineGroup
OutlineGroup
Про це йдеться в повідомленні Aspose.Note.OutlineGroup.
VisitOutlineGroupStart(OutlineGroup)
Почніть відвідувати нод Aspose.Note.OutlineGroup.
public virtual void VisitOutlineGroupStart(OutlineGroup outlineGroup)
Parameters
outlineGroup
OutlineGroup
Про це йдеться в повідомленні Aspose.Note.OutlineGroup.
VisitOutlineStart(Outline)
Почніть відвідувати Aspose.Note.Outline нод.
public virtual void VisitOutlineStart(Outline outline)
Parameters
outline
Outline
Про це йдеться в повідомленні Aspose.Note.Outline node.
VisitPageEnd(Page)
Закінчитися, щоб відвідати Aspose.Note.Page node.
public virtual void VisitPageEnd(Page page)
Parameters
page
Page
Про це йдеться в повідомленні Aspose.Note.Page nod.
VisitPageStart(Page)
Почніть відвідувати Aspose.Note.Page node.
public virtual void VisitPageStart(Page page)
Parameters
page
Page
Про це йдеться в повідомленні Aspose.Note.Page nod.
VisitRichTextEnd(RichText)
Завершиться, щоб відвідати Aspose.Note.RichText нід.
public virtual void VisitRichTextEnd(RichText richText)
Parameters
richText
RichText
Про це йдеться в повідомленні Aspose.Note.RichText.
VisitRichTextStart(RichText)
Почніть відвідувати нод Aspose.Note.RichText.
public virtual void VisitRichTextStart(RichText richText)
Parameters
richText
RichText
Про це йдеться в повідомленні Aspose.Note.RichText.
VisitTableCellEnd(TableCell)
Відвідайте нод Aspose.Note.TableCell.
public virtual void VisitTableCellEnd(TableCell tableCell)
Parameters
tableCell
TableCell
Про це йдеться в повідомленні Aspose.Note.TableCell.
VisitTableCellStart(TableCell)
Почніть відвідувати нод Aspose.Note.TableCell.
public virtual void VisitTableCellStart(TableCell tableCell)
Parameters
tableCell
TableCell
Про це йдеться в повідомленні Aspose.Note.TableCell.
VisitTableEnd(Table)
Завершиться, щоб відвідати Aspose.Note.Табельний вузол.
public virtual void VisitTableEnd(Table table)
Parameters
table
Table
Про це йдеться в повідомленні Aspose.Note.Table node.
VisitTableRowEnd(TableRow)
Завершиться, щоб відвідати Aspose.Note.TableRow вузол.
public virtual void VisitTableRowEnd(TableRow tableRow)
Parameters
tableRow
TableRow
Про це йдеться в повідомленні Aspose.Note.TableRow.
VisitTableRowStart(TableRow)
Почніть відвідувати нод Aspose.Note.TableRow.
public virtual void VisitTableRowStart(TableRow tableRow)
Parameters
tableRow
TableRow
Про це йдеться в повідомленні Aspose.Note.TableRow.
VisitTableStart(Table)
Почніть відвідувати Aspose.Note.Табельний вузол.
public virtual void VisitTableStart(Table table)
Parameters
table
Table
Про це йдеться в повідомленні Aspose.Note.Table node.
VisitTitleEnd(Title)
Закінчити, щоб відвідати Aspose.Note.Title нод.
public virtual void VisitTitleEnd(Title title)
Parameters
title
Title
Завантажити Aspose.Note.Title node
VisitTitleStart(Title)
Почніть відвідувати Aspose.Note.Title нод.
public virtual void VisitTitleStart(Title title)
Parameters
title
Title
Завантажити Aspose.Note.Title node