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

CreateSnapshot() public method

Creates a snapshot of the current text.

This method returns an immutable snapshot of the document, and may be safely called even when the document's owner thread is concurrently modifying the document.

This special thread-safety guarantee is valid only for TextDocument.CreateSnapshot(), not necessarily for other classes implementing ITextSource.CreateSnapshot().

public CreateSnapshot ( ) : ITextSource
return ITextSource
        public ITextSource CreateSnapshot()
        {
            lock (lockObject) {
                return new RopeTextSource(rope, versionProvider.CurrentVersion);
            }
        }

Same methods

TextDocument::CreateSnapshot ( int offset, int length ) : ITextSource

Usage Example

Esempio n. 1
0
		public void NoChanges()
		{
			TextDocument document = new TextDocument("initial text");
			ITextSource snapshot1 = document.CreateSnapshot();
			ITextSource snapshot2 = document.CreateSnapshot();
			Assert.AreEqual(0, snapshot1.Version.CompareAge(snapshot2.Version));
			Assert.AreEqual(0, snapshot1.Version.GetChangesTo(snapshot2.Version).Count());
			Assert.AreEqual(document.Text, snapshot1.Text);
			Assert.AreEqual(document.Text, snapshot2.Text);
		}
All Usage Examples Of ICSharpCode.AvalonEdit.Document.TextDocument::CreateSnapshot