Class DocumentVisitor

Class DocumentVisitor

Pôvodný názov: Aspose.Note Zhromaždenie: Aspose.Note.dll (25.4.0)

Abstraktná trieda pre iteráciu cez podstrom s koreňom na určenom uzle.

public abstract class DocumentVisitor

Inheritance

object DocumentVisitor

Z dedičných členov

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

Examples

Ukáže, ako získať prístup k obsahu dokumentu pomocou návštevníka.

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)

Konečne navštívte Aspose.Note.AttachedFile node.

public virtual void VisitAttachedFileEnd(AttachedFile attachedFile)

Parameters

attachedFile AttachedFile

Aspose.Note.AttachedNóda súboru.

VisitAttachedFileStart(AttachedFile)

Začnite navštevovať Aspose.Note.AttachedFile node.

public virtual void VisitAttachedFileStart(AttachedFile attachedFile)

Parameters

attachedFile AttachedFile

Aspose.Note.AttachedNóda súboru.

VisitDocumentEnd(Document)

Konečne navštívte Aspose.Note.Dokumentový uzol.

public virtual void VisitDocumentEnd(Document document)

Parameters

document Document

Aspose.Note.Dokumentný uzol

VisitDocumentStart(Document)

Začnite navštevovať Aspose.Note.Dokumentový uzol.

public virtual void VisitDocumentStart(Document document)

Parameters

document Document

Aspose.Note.Dokumentný uzol

VisitImageEnd(Image)

Konečne navštívte Aspose.Note.Image node.

public virtual void VisitImageEnd(Image image)

Parameters

image Image

Aspose.Note.obrazový uzol

VisitImageStart(Image)

Začnite navštevovať Aspose.Note.Image node.

public virtual void VisitImageStart(Image image)

Parameters

image Image

Aspose.Note.obrazový uzol

VisitInkDrawingEnd(InkDrawing)

Konečne navštívte Aspose.Note.InkDrawing node.

public virtual void VisitInkDrawingEnd(InkDrawing inkDrawing)

Parameters

inkDrawing InkDrawing

Aspose.Note.InkDrawing nôd

VisitInkDrawingStart(InkDrawing)

Začnite navštevovať Aspose.Note.InkDrawing node.

public virtual void VisitInkDrawingStart(InkDrawing inkDrawing)

Parameters

inkDrawing InkDrawing

Aspose.Note.InkDrawing nôd

VisitInkParagraphEnd(InkParagraph)

Konečne navštívte nôž Aspose.Note.InkParagraph.

public virtual void VisitInkParagraphEnd(InkParagraph inkParagraph)

Parameters

inkParagraph InkParagraph

Aspose.Note.InkParagraf nôd.

VisitInkParagraphStart(InkParagraph)

Začnite navštevovať Aspose.Note.InkParagraph node.

public virtual void VisitInkParagraphStart(InkParagraph inkParagraph)

Parameters

inkParagraph InkParagraph

Aspose.Note.InkParagraf nôd.

VisitInkWordEnd(InkWord)

Konečne navštívte Aspose.Note.InkWord node.

public virtual void VisitInkWordEnd(InkWord inkWord)

Parameters

inkWord InkWord

Aspose.Note.InkWord nôd

VisitInkWordStart(InkWord)

Začnite navštevovať Aspose.Note.InkWord node.

public virtual void VisitInkWordStart(InkWord inkWord)

Parameters

inkWord InkWord

Aspose.Note.InkWord nôd

VisitLoopEnd(Loop)

Konečne navštívte Aspose.Note.Loop node.

public virtual void VisitLoopEnd(Loop loop)

Parameters

loop Loop

WL31_.Loop nôd je k dispozícii.

VisitLoopStart(Loop)

Začnite navštevovať Aspose.Note.Loop node.

public virtual void VisitLoopStart(Loop loop)

Parameters

loop Loop

WL31_.Loop nôd je k dispozícii.

VisitOutlineElementEnd(OutlineElement)

Konečne navštívte Aspose.Note.OutlineElement node.

public virtual void VisitOutlineElementEnd(OutlineElement outlineElement)

Parameters

outlineElement OutlineElement

Aspose.Note.OutlineNóda prvku.

VisitOutlineElementStart(OutlineElement)

Začnite navštevovať Aspose.Note.OutlineElement node.

public virtual void VisitOutlineElementStart(OutlineElement outlineElement)

Parameters

outlineElement OutlineElement

Aspose.Note.OutlineNóda prvku.

VisitOutlineEnd(Outline)

Konečne navštívte Aspose.Note.Outline uzol.

public virtual void VisitOutlineEnd(Outline outline)

Parameters

outline Outline

Aspose.Note.Outline nôd

VisitOutlineGroupEnd(OutlineGroup)

Konečne navštívte Aspose.Note.OutlineGroup node.

public virtual void VisitOutlineGroupEnd(OutlineGroup outlineGroup)

Parameters

outlineGroup OutlineGroup

Aspose.Note.OutlineGroup nôd

VisitOutlineGroupStart(OutlineGroup)

Začnite navštevovať Aspose.Note.OutlineGroup node.

public virtual void VisitOutlineGroupStart(OutlineGroup outlineGroup)

Parameters

outlineGroup OutlineGroup

Aspose.Note.OutlineGroup nôd

VisitOutlineStart(Outline)

Začnite navštevovať Aspose.Note.Outline uzol.

public virtual void VisitOutlineStart(Outline outline)

Parameters

outline Outline

Aspose.Note.Outline nôd

VisitPageEnd(Page)

Konečne navštívte Aspose.Note.Page node.

public virtual void VisitPageEnd(Page page)

Parameters

page Page

Stránka Aspose.Note.

VisitPageStart(Page)

Začnite navštevovať Aspose.Note.Page node.

public virtual void VisitPageStart(Page page)

Parameters

page Page

Stránka Aspose.Note.

VisitRichTextEnd(RichText)

Konečne navštívte Aspose.Note.RichText node.

public virtual void VisitRichTextEnd(RichText richText)

Parameters

richText RichText

Aspose.Note.RichText nôd

VisitRichTextStart(RichText)

Začnite navštevovať Aspose.Note.RichText node.

public virtual void VisitRichTextStart(RichText richText)

Parameters

richText RichText

Aspose.Note.RichText nôd

VisitTableCellEnd(TableCell)

Konečne navštívte Aspose.Note.TableCell node.

public virtual void VisitTableCellEnd(TableCell tableCell)

Parameters

tableCell TableCell

Aspose.Note.TableCell nôd

VisitTableCellStart(TableCell)

Začnite navštevovať Aspose.Note.TableCell node.

public virtual void VisitTableCellStart(TableCell tableCell)

Parameters

tableCell TableCell

Aspose.Note.TableCell nôd

VisitTableEnd(Table)

Konečne navštívte Aspose.Note.Tabuľkový uzol.

public virtual void VisitTableEnd(Table table)

Parameters

table Table

WL31_. tabuľkový uzol

VisitTableRowEnd(TableRow)

Konečne navštívte Aspose.Note.TableRow uzol.

public virtual void VisitTableRowEnd(TableRow tableRow)

Parameters

tableRow TableRow

Aspose.Note.TableRow nôd

VisitTableRowStart(TableRow)

Začnite navštevovať Aspose.Note.TableRow uzol.

public virtual void VisitTableRowStart(TableRow tableRow)

Parameters

tableRow TableRow

Aspose.Note.TableRow nôd

VisitTableStart(Table)

Začnite navštevovať Aspose.Note.Tabuľkový uzol.

public virtual void VisitTableStart(Table table)

Parameters

table Table

WL31_. tabuľkový uzol

VisitTitleEnd(Title)

Konečne navštívte Aspose.Note.Title node.

public virtual void VisitTitleEnd(Title title)

Parameters

title Title

Aspose.Note.Titľový uzol

VisitTitleStart(Title)

Začnite navštevovať Aspose.Note.Title node.

public virtual void VisitTitleStart(Title title)

Parameters

title Title

Aspose.Note.Titľový uzol

 Slovenčina