ICSharpCode.AvalonEdit.Editing.Selection.GetText C# (CSharp) Method

GetText() public method

Gets the selected text.
public GetText ( TextDocument document ) : string
document ICSharpCode.AvalonEdit.Document.TextDocument
return string
        public virtual string GetText(TextDocument document)
        {
            if (document == null)
                throw new ArgumentNullException("document");
            StringBuilder b = null;
            string text = null;
            foreach (ISegment s in Segments) {
                if (text != null) {
                    if (b == null)
                        b = new StringBuilder(text);
                    else
                        b.Append(text);
                }
                text = document.GetText(s);
            }
            if (b != null) {
                if (text != null) b.Append(text);
                return b.ToString();
            } else {
                return text ?? string.Empty;
            }
        }