officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-da07a8c9.md
A base class implementing the IDocumentVisitor interface.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
public abstract class DocumentVisitorBase :
IDocumentVisitor
Public MustInherit Class DocumentVisitorBase
Implements IDocumentVisitor
Use the DocumentVisitorBase instead of your custom implementation to keep up with the actual state of the IDocumentVisitor interface in the event of possible modifications in the future.
MyVisitor is a DocumentVisitorBase class descendant which provides a method that processes DocumentText elements to do the following.
Other document elements are skipped.
public class MyVisitor : DocumentVisitorBase
{
readonly StringBuilder buffer;
public MyVisitor() { this.buffer = new StringBuilder(); }
protected StringBuilder Buffer { get { return buffer; } }
public string Text { get { return Buffer.ToString(); } }
public override void Visit(DocumentText text) {
string prefix = (text.TextProperties.FontBold) ? "**" : "";
Buffer.Append(prefix);
Buffer.Append(text.Text);
Buffer.Append(prefix);
}
public override void Visit(DocumentParagraphEnd paragraphEnd) {
Buffer.AppendLine();
}
}
Public Class MyVisitor
Inherits DocumentVisitorBase
Private ReadOnly buffer_Renamed As StringBuilder
Public Sub New()
Me.buffer_Renamed = New StringBuilder()
End Sub
Protected ReadOnly Property Buffer() As StringBuilder
Get
Return buffer_Renamed
End Get
End Property
Public ReadOnly Property Text() As String
Get
Return ToString()
End Get
End Property
Public Overrides Sub Visit(ByVal text As DocumentText)
Dim prefix As String = If(text.TextProperties.FontBold, "**", "")
Buffer.Append(prefix)
Buffer.Append(text.Text)
Buffer.Append(prefix)
End Sub
Public Overrides Sub Visit(ByVal paragraphEnd As DocumentParagraphEnd)
Buffer.AppendLine()
End Sub
End Class
Object DocumentVisitorBase
See Also