Class DocumentVisitor

Class DocumentVisitor

Tên không gian: Aspose.Note Tổng hợp: Aspose.Note.dll (25.4.0)

Lớp trừu tượng cho iterating thông qua tầng hầm với rễ ở nút được chỉ định.

public abstract class DocumentVisitor

Inheritance

object DocumentVisitor

Thành viên thừa kế

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Hiển thị cách truy cập nội dung của một tài liệu bằng cách sử dụng khách.

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)

Kết thúc để truy cập Aspose.Note.AttachedFile nút.

public virtual void VisitAttachedFileEnd(AttachedFile attachedFile)

Parameters

attachedFile AttachedFile

Các Aspose.Note.AttachedFile nút.

VisitAttachedFileStart(AttachedFile)

Bắt đầu để truy cập Aspose.Note.AttachedFile nút.

public virtual void VisitAttachedFileStart(AttachedFile attachedFile)

Parameters

attachedFile AttachedFile

Các Aspose.Note.AttachedFile nút.

VisitDocumentEnd(Document)

Kết thúc để truy cập Aspose.Note.Document node.

public virtual void VisitDocumentEnd(Document document)

Parameters

document Document

WL31_.Nút tài liệu

VisitDocumentStart(Document)

Bắt đầu để truy cập Aspose.Note.Document node.

public virtual void VisitDocumentStart(Document document)

Parameters

document Document

WL31_.Nút tài liệu

VisitImageEnd(Image)

Kết thúc để truy cập Aspose.Note.Image node.

public virtual void VisitImageEnd(Image image)

Parameters

image Image

Các Aspose.Note.Image node.

VisitImageStart(Image)

Bắt đầu để truy cập Aspose.Note.Image node.

public virtual void VisitImageStart(Image image)

Parameters

image Image

Các Aspose.Note.Image node.

VisitInkDrawingEnd(InkDrawing)

Kết thúc để truy cập Aspose.Note.InkDrawing nút.

public virtual void VisitInkDrawingEnd(InkDrawing inkDrawing)

Parameters

inkDrawing InkDrawing

Các Aspose.Note.InkDrawing nút.

VisitInkDrawingStart(InkDrawing)

Bắt đầu để truy cập Aspose.Note.InkDrawing nút.

public virtual void VisitInkDrawingStart(InkDrawing inkDrawing)

Parameters

inkDrawing InkDrawing

Các Aspose.Note.InkDrawing nút.

VisitInkParagraphEnd(InkParagraph)

Kết thúc để truy cập vào nút Aspose.Note.InkParagraph.

public virtual void VisitInkParagraphEnd(InkParagraph inkParagraph)

Parameters

inkParagraph InkParagraph

Các Aspose.Note.InkParagraph nút.

VisitInkParagraphStart(InkParagraph)

Bắt đầu để truy cập Aspose.Note.InkParagraph nút.

public virtual void VisitInkParagraphStart(InkParagraph inkParagraph)

Parameters

inkParagraph InkParagraph

Các Aspose.Note.InkParagraph nút.

VisitInkWordEnd(InkWord)

Kết thúc để truy cập Aspose.Note.InkWord nút.

public virtual void VisitInkWordEnd(InkWord inkWord)

Parameters

inkWord InkWord

Nhóm _WL31 _.InkWord

VisitInkWordStart(InkWord)

Bắt đầu để truy cập Aspose.Note.InkWord nút.

public virtual void VisitInkWordStart(InkWord inkWord)

Parameters

inkWord InkWord

Nhóm _WL31 _.InkWord

VisitLoopEnd(Loop)

Kết thúc để truy cập Aspose.Note.Loop node.

public virtual void VisitLoopEnd(Loop loop)

Parameters

loop Loop

Các Aspose.Note.Loop nút.

VisitLoopStart(Loop)

Bắt đầu để truy cập Aspose.Note.Loop nút.

public virtual void VisitLoopStart(Loop loop)

Parameters

loop Loop

Các Aspose.Note.Loop nút.

VisitOutlineElementEnd(OutlineElement)

Kết thúc để truy cập Aspose.Note.OutlineElement nút.

public virtual void VisitOutlineElementEnd(OutlineElement outlineElement)

Parameters

outlineElement OutlineElement

Các Aspose.Note.OutlineElement nút.

VisitOutlineElementStart(OutlineElement)

Bắt đầu để truy cập Aspose.Note.OutlineElement nút.

public virtual void VisitOutlineElementStart(OutlineElement outlineElement)

Parameters

outlineElement OutlineElement

Các Aspose.Note.OutlineElement nút.

VisitOutlineEnd(Outline)

Kết thúc để truy cập Aspose.Note.Outline nút.

public virtual void VisitOutlineEnd(Outline outline)

Parameters

outline Outline

Các Aspose.Note.Outline nút.

VisitOutlineGroupEnd(OutlineGroup)

Kết thúc để truy cập Aspose.Note.OutlineGroup nút.

public virtual void VisitOutlineGroupEnd(OutlineGroup outlineGroup)

Parameters

outlineGroup OutlineGroup

Các Aspose.Note.OutlineGroup nút.

VisitOutlineGroupStart(OutlineGroup)

Bắt đầu để truy cập Aspose.Note.OutlineGroup nút.

public virtual void VisitOutlineGroupStart(OutlineGroup outlineGroup)

Parameters

outlineGroup OutlineGroup

Các Aspose.Note.OutlineGroup nút.

VisitOutlineStart(Outline)

Bắt đầu để truy cập Aspose.Note.Outline nút.

public virtual void VisitOutlineStart(Outline outline)

Parameters

outline Outline

Các Aspose.Note.Outline nút.

VisitPageEnd(Page)

Kết thúc để truy cập Aspose.Note.Page node.

public virtual void VisitPageEnd(Page page)

Parameters

page Page

Các Aspose.Note.Page nút.

VisitPageStart(Page)

Bắt đầu để truy cập Aspose.Note.Page node.

public virtual void VisitPageStart(Page page)

Parameters

page Page

Các Aspose.Note.Page nút.

VisitRichTextEnd(RichText)

Kết thúc để truy cập Aspose.Note.RichText nút.

public virtual void VisitRichTextEnd(RichText richText)

Parameters

richText RichText

Các Aspose.Note.RichText nút.

VisitRichTextStart(RichText)

Bắt đầu để truy cập Aspose.Note.RichText nút.

public virtual void VisitRichTextStart(RichText richText)

Parameters

richText RichText

Các Aspose.Note.RichText nút.

VisitTableCellEnd(TableCell)

Kết thúc để truy cập Aspose.Note.TableCell nút.

public virtual void VisitTableCellEnd(TableCell tableCell)

Parameters

tableCell TableCell

WL31_.TableCell nút

VisitTableCellStart(TableCell)

Bắt đầu để truy cập Aspose.Note.TableCell nút.

public virtual void VisitTableCellStart(TableCell tableCell)

Parameters

tableCell TableCell

WL31_.TableCell nút

VisitTableEnd(Table)

Kết thúc để truy cập vào Aspose.Note.Table node.

public virtual void VisitTableEnd(Table table)

Parameters

table Table

Các Aspose.Note.Nút bảng.

VisitTableRowEnd(TableRow)

Kết thúc để truy cập Aspose.Note.TableRow nút.

public virtual void VisitTableRowEnd(TableRow tableRow)

Parameters

tableRow TableRow

WL31_.TableRow nút

VisitTableRowStart(TableRow)

Bắt đầu để truy cập Aspose.Note.TableRow nút.

public virtual void VisitTableRowStart(TableRow tableRow)

Parameters

tableRow TableRow

WL31_.TableRow nút

VisitTableStart(Table)

Bắt đầu để truy cập Aspose.Note.Table node.

public virtual void VisitTableStart(Table table)

Parameters

table Table

Các Aspose.Note.Nút bảng.

VisitTitleEnd(Title)

Kết thúc để truy cập Aspose.Note.Title node.

public virtual void VisitTitleEnd(Title title)

Parameters

title Title

WL31_.Nút tiêu đề

VisitTitleStart(Title)

Bắt đầu bằng cách truy cập Aspose.Note.Title node.

public virtual void VisitTitleStart(Title title)

Parameters

title Title

WL31_.Nút tiêu đề

 Tiếng Việt