ICSharpCode.AvalonEdit.Document.TextDocument.GetTextFromTextSource C# (CSharp) Method

GetTextFromTextSource() static private method

static private GetTextFromTextSource ( ITextSource textSource ) : IEnumerable
textSource ITextSource
return IEnumerable
        static IEnumerable<char> GetTextFromTextSource(ITextSource textSource)
        {
            if (textSource == null)
                throw new ArgumentNullException("textSource");

            if (textSource is ReadOnlyDocument)
                textSource = textSource.CreateSnapshot(); // retrieve underlying text source, which might be a RopeTextSource

            RopeTextSource rts = textSource as RopeTextSource;
            if (rts != null)
                return rts.GetRope();

            TextDocument doc = textSource as TextDocument;
            if (doc != null)
                return doc.rope;

            return textSource.Text;
        }