private void TraverseRightObject(IMDTreeItem Right, ComparisonItem ParentNode) { if (Right.HasChildren()) { foreach (var item in Right.ChildItems) { AddAndFillNewNode(null, item, ParentNode); } } if (Right is IMDPropertyProvider) { var PropStub = ParentNode.AddStaticNode("Свойства"); var PropProv = Right as IMDPropertyProvider; foreach (PropDef propDef in PropProv.Properties.Values) { var propNode = new ComparisonItem(null, propDef.Value, propDef.Name); propNode.IsDiffer = true; PropStub.Items.Add(propNode); } PropStub.IsDiffer = true; } }
private void FillComparisonNode(IMDTreeItem Left, IMDTreeItem Right, ComparisonItem node) { if ((Left != null && Right != null) && Left.GetType() != Right.GetType()) { throw new InvalidOperationException("Compared components must be of the same type"); } FillSide(node.Left, Left); FillSide(node.Right, Right); if (Left == null) { TraverseRightObject(Right, node); return; } if (Left is IMDPropertyProvider) { CompareProperties((IMDPropertyProvider)Left, (IMDPropertyProvider)Right, node); } if (Left is IComparableItem) { // Разница определяется самим объектом node.IsDiffer = !((IComparableItem)Left).CompareTo(Right); } else if (Left is MDObjectsCollection <MDObjectBase> || Left is StaticTreeNode) { MapAndCompareCollections(Left, Right, node); } else if (Left.HasChildren()) { // это статичные свойства метаданных // порядок свойств будет соблюдаться в обоих объектах var LeftWalker = Left.ChildItems.GetEnumerator(); IEnumerator <IMDTreeItem> RightWalker = null; if (Right != null) { RightWalker = Right.ChildItems.GetEnumerator(); } while (LeftWalker.MoveNext()) { var newNode = new ComparisonItem(); if (Right != null) { RightWalker.MoveNext(); FillComparisonNode(LeftWalker.Current, RightWalker.Current, newNode); } else { FillComparisonNode(LeftWalker.Current, null, newNode); } if (!(newNode.Left == null && newNode.Right == null)) { node.Items.Add(newNode); node.IsDiffer = node.IsDiffer || newNode.IsDiffer; } } } }