CreateSnapshot() public méthode

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
Résultat ITextSource
		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);
		}
Exemple #2
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);
        }
Exemple #3
0
		public void NoChanges()
		{
			TextDocument document = new TextDocument("initial text");
			ChangeTrackingCheckpoint checkpoint1, checkpoint2;
			ITextSource snapshot1 = document.CreateSnapshot(out checkpoint1);
			ITextSource snapshot2 = document.CreateSnapshot(out checkpoint2);
			Assert.AreEqual(0, checkpoint1.CompareAge(checkpoint2));
			Assert.AreEqual(0, checkpoint1.GetChangesTo(checkpoint2).Count());
			Assert.AreEqual(document.Text, snapshot1.Text);
			Assert.AreEqual(document.Text, snapshot2.Text);
		}
        public void NoChanges()
        {
            TextDocument             document = new TextDocument("initial text");
            ChangeTrackingCheckpoint checkpoint1, checkpoint2;
            ITextSource snapshot1 = document.CreateSnapshot(out checkpoint1);
            ITextSource snapshot2 = document.CreateSnapshot(out checkpoint2);

            Assert.AreEqual(0, checkpoint1.CompareAge(checkpoint2));
            Assert.AreEqual(0, checkpoint1.GetChangesTo(checkpoint2).Count());
            Assert.AreEqual(document.Text, snapshot1.Text);
            Assert.AreEqual(document.Text, snapshot2.Text);
        }
		public void BackwardChanges()
		{
			TextDocument document = new TextDocument("initial text");
			ITextSource snapshot1 = document.CreateSnapshot();
			document.Replace(0, 7, "nw");
			document.Insert(1, "e");
			ITextSource snapshot2 = document.CreateSnapshot();
			Assert.AreEqual(1, snapshot2.Version.CompareAge(snapshot1.Version));
			TextChangeEventArgs[] arr = snapshot2.Version.GetChangesTo(snapshot1.Version).ToArray();
			Assert.AreEqual(2, arr.Length);
			Assert.AreEqual("", arr[0].InsertedText.Text);
			Assert.AreEqual("initial", arr[1].InsertedText.Text);
			
			Assert.AreEqual("initial text", snapshot1.Text);
			Assert.AreEqual("new text", snapshot2.Text);
		}
Exemple #6
0
		public void BackwardChanges()
		{
			TextDocument document = new TextDocument("initial text");
			ChangeTrackingCheckpoint checkpoint1, checkpoint2;
			ITextSource snapshot1 = document.CreateSnapshot(out checkpoint1);
			document.Replace(0, 7, "nw");
			document.Insert(1, "e");
			ITextSource snapshot2 = document.CreateSnapshot(out checkpoint2);
			Assert.AreEqual(1, checkpoint2.CompareAge(checkpoint1));
			DocumentChangeEventArgs[] arr = checkpoint2.GetChangesTo(checkpoint1).ToArray();
			Assert.AreEqual(2, arr.Length);
			Assert.AreEqual("", arr[0].InsertedText);
			Assert.AreEqual("initial", arr[1].InsertedText);
			
			Assert.AreEqual("initial text", snapshot1.Text);
			Assert.AreEqual("new text", snapshot2.Text);
		}
Exemple #7
0
        public void BackwardChanges()
        {
            TextDocument document  = new TextDocument("initial text");
            ITextSource  snapshot1 = document.CreateSnapshot();

            document.Replace(0, 7, "nw");
            document.Insert(1, "e");
            ITextSource snapshot2 = document.CreateSnapshot();

            Assert.AreEqual(1, snapshot2.Version.CompareAge(snapshot1.Version));
            TextChangeEventArgs[] arr = snapshot2.Version.GetChangesTo(snapshot1.Version).ToArray();
            Assert.AreEqual(2, arr.Length);
            Assert.AreEqual("", arr[0].InsertedText.Text);
            Assert.AreEqual("initial", arr[1].InsertedText.Text);

            Assert.AreEqual("initial text", snapshot1.Text);
            Assert.AreEqual("new text", snapshot2.Text);
        }
        public void BackwardChanges()
        {
            TextDocument             document = new TextDocument("initial text");
            ChangeTrackingCheckpoint checkpoint1, checkpoint2;
            ITextSource snapshot1 = document.CreateSnapshot(out checkpoint1);

            document.Replace(0, 7, "nw");
            document.Insert(1, "e");
            ITextSource snapshot2 = document.CreateSnapshot(out checkpoint2);

            Assert.AreEqual(1, checkpoint2.CompareAge(checkpoint1));
            DocumentChangeEventArgs[] arr = checkpoint2.GetChangesTo(checkpoint1).ToArray();
            Assert.AreEqual(2, arr.Length);
            Assert.AreEqual("", arr[0].InsertedText);
            Assert.AreEqual("initial", arr[1].InsertedText);

            Assert.AreEqual("initial text", snapshot1.Text);
            Assert.AreEqual("new text", snapshot2.Text);
        }