Get diff
This explains how to get diff information for a project.
public void GetAllDifference(ICommandContext c, ICommandParams p)
{
//Get the comparison results for the current project
var project = c.App.Workspace.CurrentProject;
IModelComparison comparison = c.App.Diff.GetComparison(project);
//Get the comparison information that extracts the differences
IMatchCollection matches = comparison.GetDifferencedMatches();
foreach (IMatch match in matches)
{
foreach (IDifference difference in match.Differences)
{
if (difference.IsNewItem)
{
//For additional differences, get the added model with IMatch.Reference
IModel model = match.Reference;
c.App.Output.WriteLine("Show Diff", $"{model.Name} has been added.");
}
if (difference.IsOldItem)
{
//In the case of deletion diff, the deleted model is obtained with IMatch.Target
IModel model = match.Target;
c.App.Output.WriteLine("Show Diff", $"{model.Name} has been deleted.");
}
if (difference.IsUpdateItem)
{
IModel model = match.Reference;
c.App.Output.WriteLine("Show Diff", $"Field: {difference.Field} of {model.Name} has been updated from {difference.OldValue} to {difference.NewValue}.");
}
}
}