public OcadDiff GetDiff() { var source = new OcadFileReader(SourceFile).ReadProject(); var target = new OcadFileReader(TargetFile).ReadProject(); var diff = new OcadDiff() {Source = source, Target = target}; CompareObjects(source, target, diff); return diff; }
public OcadDiff GetDiff() { var source = new OcadFileReader(SourceFile).ReadProject(); var target = new OcadFileReader(TargetFile).ReadProject(); var diff = new OcadDiff() { Source = source, Target = target }; CompareObjects(source, target, diff); return(diff); }
private void CompareObjects(OcadBaseProject source, OcadBaseProject target, OcadDiff diff) { // Copy object lists var srcObjects = new List<OcadFileOcadObject>(source.Objects); var tarObjects = new List<OcadFileOcadObject>(target.Objects); foreach (var obj in srcObjects) { var foundObject = tarObjects.FirstOrDefault(_ => _.Equals(obj)); if (foundObject == null) { diff.DeletedObjects.Add(obj); } else { tarObjects.Remove(foundObject); } } diff.AddedObjects.AddRange(tarObjects); }
private void CompareObjects(OcadBaseProject source, OcadBaseProject target, OcadDiff diff) { // Copy object lists var srcObjects = new List <OcadFileOcadObject>(source.Objects); var tarObjects = new List <OcadFileOcadObject>(target.Objects); foreach (var obj in srcObjects) { var foundObject = tarObjects.FirstOrDefault(_ => _.Equals(obj)); if (foundObject == null) { diff.DeletedObjects.Add(obj); } else { tarObjects.Remove(foundObject); } } diff.AddedObjects.AddRange(tarObjects); }