RevisionCollection Class
A collection of Revision objects that represent revisions in the document.
Inheritance Hierarchy
SystemObject
  Aspose.WordsRevisionCollection

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public class RevisionCollection : IEnumerable<Revision>, 
	IEnumerable

The RevisionCollection type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleCount
Returns the number of revisions in the collection.
Public propertyCode exampleGroups
Collection of revision groups.
Public propertyCode exampleItem
Returns a Revision at the specified index.
Methods
  NameDescription
Public methodCode exampleAcceptAll
Accepts all revisions in this collection.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns an enumerator object.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleRejectAll
Rejects all revisions in this collection.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Remarks

You do not create instances of this class directly. Use the Revisions property to get revisions present in a document.

Examples
Shows how to check if a document has revisions.
[C#]

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Normal editing of the document does not count as a revision
builder.Write("This does not count as a revision. ");
Assert.IsFalse(doc.HasRevisions);

// In order for our edits to count as revisions, we need to declare an author and start tracking them
doc.StartTrackRevisions("John Doe", DateTime.Now);
builder.Write("This is revision #1. ");

// This flag corresponds to the "Track Changes" option being turned on in Microsoft Word, to track the editing manually
// done there and not the programmatic changes we are about to do here
Assert.IsFalse(doc.TrackRevisions);

// As well as nodes in the document, revisions get referenced in this collection
Assert.IsTrue(doc.HasRevisions);
Assert.AreEqual(1, doc.Revisions.Count);

Revision revision = doc.Revisions[0];
Assert.AreEqual("John Doe", revision.Author);
Assert.AreEqual("This is revision #1. ", revision.ParentNode.GetText());
Assert.AreEqual(RevisionType.Insertion, revision.RevisionType);
Assert.AreEqual(revision.DateTime.Date, DateTime.Now.Date);
Assert.AreEqual(doc.Revisions.Groups[0], revision.Group);

// Deleting content also counts as a revision
// The most recent revisions are put at the start of the collection
doc.FirstSection.Body.FirstParagraph.Runs[0].Remove();
Assert.AreEqual(RevisionType.Deletion, doc.Revisions[0].RevisionType);
Assert.AreEqual(2, doc.Revisions.Count);

// Insert revisions are treated as document text by the GetText() method before they are accepted,
// since they are still nodes with text and are in the body
Assert.AreEqual("This does not count as a revision. This is revision #1.", doc.GetText().Trim());

// Accepting the deletion revision will assimilate it into the paragraph text and remove it from the collection
doc.Revisions[0].Accept();
Assert.AreEqual(1, doc.Revisions.Count);

// Once the delete revision is accepted, the nodes that it concerns are removed and their text will not show up here
Assert.AreEqual("This is revision #1.", doc.GetText().Trim());

// The second insertion revision is now at index 0, which we can reject to ignore and discard it
doc.Revisions[0].Reject();
Assert.AreEqual(0, doc.Revisions.Count);
Assert.AreEqual("", doc.GetText().Trim());

// This takes us back to not counting changes as revisions
doc.StopTrackRevisions();

builder.Writeln("This also does not count as a revision.");
Assert.AreEqual(0, doc.Revisions.Count);

doc.Save(ArtifactsDir + "Document.Revisions.docx");
See Also