GroupDocs.Comparison allows you to merge source code files by using the ComparisonAction properties:
ComparisonAction.ACCEPT accepts the found changes and adds them to the file without highlighting
ComparisonAction.REJECT rejects the found changes and removes them from the output file
To apply/reject changes to the output file, follow these steps:
Instantiate the Comparer object. Specify the source document path or stream.
Call the add() method. Specify the target document path or stream.
Call the compare() method.
Call the getChanges() method to get the list of changes.
Call the setComparisonAction() method of the appropriate change object. Specify the ComparisonAction.ACCEPT or the ComparisonAction.REJECT value.
Call the applyChanges() method. Specify the collection of changes.
For example, you need to compare and merge several versions of source code files and accept or discard changes made by different persons.
The differences show that the two methods are in the source.cs file: AddNumbers and Sum.
If you do not use the ComparisonAction property, all changes are committed to the output file, and these methods are removed. If you need to control the merging of files, the ComparisonAction property helps you.
The following code snippet shows how to merge two source code files: