Class DocumentVisitor

Class DocumentVisitor

نام ها : Aspose.Note جمع آوری: WL31_.dll (25.4.0)

کلاس استثنایی برای iterating از طریق زیر درخت با ریشه در گره مشخص شده.

public abstract class DocumentVisitor

Inheritance

object DocumentVisitor

اعضای ارثی

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)

در نهایت برای بازدید از WL31_.AttachedFile نود.

public virtual void VisitAttachedFileEnd(AttachedFile attachedFile)

Parameters

attachedFile AttachedFile

WL31_.نود فایل اضافه شده است.

VisitAttachedFileStart(AttachedFile)

برای شروع به بازدید از WL31_.AttachedFile نود.

public virtual void VisitAttachedFileStart(AttachedFile attachedFile)

Parameters

attachedFile AttachedFile

WL31_.نود فایل اضافه شده است.

VisitDocumentEnd(Document)

برای بازدید از WL31_.Document node به پایان می رسد.

public virtual void VisitDocumentEnd(Document document)

Parameters

document Document

_WL31 _ .نود اسناد

VisitDocumentStart(Document)

برای شروع به بازدید از WL31_.Document node.

public virtual void VisitDocumentStart(Document document)

Parameters

document Document

_WL31 _ .نود اسناد

VisitImageEnd(Image)

برای بازدید از WL31_.Image node به پایان می رسد.

public virtual void VisitImageEnd(Image image)

Parameters

image Image

_WL31 _ نود تصویر

VisitImageStart(Image)

برای شروع به بازدید از WL31_.Image نود.

public virtual void VisitImageStart(Image image)

Parameters

image Image

_WL31 _ نود تصویر

VisitInkDrawingEnd(InkDrawing)

برای بازدید از WL31_.InkDrawing node به پایان می رسد.

public virtual void VisitInkDrawingEnd(InkDrawing inkDrawing)

Parameters

inkDrawing InkDrawing

WL31.InkDrawing نود است.

VisitInkDrawingStart(InkDrawing)

برای شروع به بازدید از WL31_.InkDrawing نود.

public virtual void VisitInkDrawingStart(InkDrawing inkDrawing)

Parameters

inkDrawing InkDrawing

WL31.InkDrawing نود است.

VisitInkParagraphEnd(InkParagraph)

در نهایت برای بازدید از WL31_.Inkنود پاراگراف.

public virtual void VisitInkParagraphEnd(InkParagraph inkParagraph)

Parameters

inkParagraph InkParagraph

WL31_.Inkنود پاراگراف

VisitInkParagraphStart(InkParagraph)

شروع به بازدید از WL31_.Inkنود پاراگراف.

public virtual void VisitInkParagraphStart(InkParagraph inkParagraph)

Parameters

inkParagraph InkParagraph

WL31_.Inkنود پاراگراف

VisitInkWordEnd(InkWord)

در نهایت برای بازدید از WL31_.InkWord گره.

public virtual void VisitInkWordEnd(InkWord inkWord)

Parameters

inkWord InkWord

_WL31 _.InkWord نود است.

VisitInkWordStart(InkWord)

برای شروع به بازدید از WL31_.InkWord گره.

public virtual void VisitInkWordStart(InkWord inkWord)

Parameters

inkWord InkWord

_WL31 _.InkWord نود است.

VisitLoopEnd(Loop)

در نهایت برای بازدید از WL31_.Loop نود.

public virtual void VisitLoopEnd(Loop loop)

Parameters

loop Loop

_WL31 _.نود کلوب .

VisitLoopStart(Loop)

برای شروع به بازدید از WL31_.Loop نود.

public virtual void VisitLoopStart(Loop loop)

Parameters

loop Loop

_WL31 _.نود کلوب .

VisitOutlineElementEnd(OutlineElement)

در نهایت به WL31_.OutlineElement نود مراجعه کنید.

public virtual void VisitOutlineElementEnd(OutlineElement outlineElement)

Parameters

outlineElement OutlineElement

WL31_.Outlineنود عناصر

VisitOutlineElementStart(OutlineElement)

برای شروع به بازدید از WL31_.OutlineElement گره.

public virtual void VisitOutlineElementStart(OutlineElement outlineElement)

Parameters

outlineElement OutlineElement

WL31_.Outlineنود عناصر

VisitOutlineEnd(Outline)

در نهایت برای بازدید از WL31_.Outline گره.

public virtual void VisitOutlineEnd(Outline outline)

Parameters

outline Outline

_WL31 _.نود خارج از خط

VisitOutlineGroupEnd(OutlineGroup)

در نهایت به WL31_.OutlineGroup نود مراجعه کنید.

public virtual void VisitOutlineGroupEnd(OutlineGroup outlineGroup)

Parameters

outlineGroup OutlineGroup

WL31_.OutlineGroup نود است.

VisitOutlineGroupStart(OutlineGroup)

برای شروع به بازدید از WL31_.OutlineGroup گره.

public virtual void VisitOutlineGroupStart(OutlineGroup outlineGroup)

Parameters

outlineGroup OutlineGroup

WL31_.OutlineGroup نود است.

VisitOutlineStart(Outline)

برای شروع به بازدید از WL31_.Outline گره.

public virtual void VisitOutlineStart(Outline outline)

Parameters

outline Outline

_WL31 _.نود خارج از خط

VisitPageEnd(Page)

برای بازدید از WL31_.Page node به پایان می رسد.

public virtual void VisitPageEnd(Page page)

Parameters

page Page

_WL31 _.نود صفحه

VisitPageStart(Page)

شروع به بازدید از WL31_.نود صفحه.

public virtual void VisitPageStart(Page page)

Parameters

page Page

_WL31 _.نود صفحه

VisitRichTextEnd(RichText)

در پایان به نوت Aspose.Note.RichText مراجعه کنید.

public virtual void VisitRichTextEnd(RichText richText)

Parameters

richText RichText

WL31_.RichText نود است.

VisitRichTextStart(RichText)

برای شروع به بازدید از WL31_.RichText گره.

public virtual void VisitRichTextStart(RichText richText)

Parameters

richText RichText

WL31_.RichText نود است.

VisitTableCellEnd(TableCell)

در پایان به نوت WL31_.TableCell مراجعه کنید.

public virtual void VisitTableCellEnd(TableCell tableCell)

Parameters

tableCell TableCell

_WL31 _.TableCell نود

VisitTableCellStart(TableCell)

برای شروع به بازدید از WL31_.TableCell گره.

public virtual void VisitTableCellStart(TableCell tableCell)

Parameters

tableCell TableCell

_WL31 _.TableCell نود

VisitTableEnd(Table)

به پایان می رسد برای بازدید از WL31_.نود جدول.

public virtual void VisitTableEnd(Table table)

Parameters

table Table

_WL31 _ نود جدول

VisitTableRowEnd(TableRow)

در نهایت برای بازدید از WL31_.TableRow گره.

public virtual void VisitTableRowEnd(TableRow tableRow)

Parameters

tableRow TableRow

نود _WL31 _.TableRow

VisitTableRowStart(TableRow)

برای شروع به بازدید از WL31_.TableRow گره.

public virtual void VisitTableRowStart(TableRow tableRow)

Parameters

tableRow TableRow

نود _WL31 _.TableRow

VisitTableStart(Table)

شروع به بازدید از WL31_.نود جدول.

public virtual void VisitTableStart(Table table)

Parameters

table Table

_WL31 _ نود جدول

VisitTitleEnd(Title)

برای بازدید از WL31_.Title node به پایان می رسد.

public virtual void VisitTitleEnd(Title title)

Parameters

title Title

_WL31 _ نود عنوان

VisitTitleStart(Title)

برای شروع به بازدید از WL31_.Title نود.

public virtual void VisitTitleStart(Title title)

Parameters

title Title

_WL31 _ نود عنوان

 فارسی