DocumentVisitorBase Class
A base class implementing the IDocumentVisitor interface.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v24.2.Core.dll
NuGet Package: DevExpress.RichEdit.Core
#Declaration
public abstract class DocumentVisitorBase :
IDocumentVisitor
#Remarks
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.
#Example
MyVisitor is a DocumentVisitorBase class descendant which provides a method that processes DocumentText elements to do the following.
- Enclose the bold text in asterisks
- Return all characters without formatting
- Replace the paragraph ends with newline symbols
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();
}
}