private int?CompareObjects(IMDTreeItem left, IMDTreeItem right)
 {
     if (left.GetType() == right.GetType())
     {
         if (m_CurrentMode == MatchingMode.ByID)
         {
             return(String.CompareOrdinal(left.Key, right.Key));
         }
         else
         {
             return(String.CompareOrdinal(left.Text, right.Text));
         }
     }
     else
     {
         return(null);
     }
 }
        private void InstantiateObject(V8MetadataContainer cnt, ref IMDTreeItem obj)
        {
            if (obj == null)
            {
                var tmpObj = cnt.RaiseObject();

                if (tmpObj is IMDTreeItem)
                {
                    obj = (IMDTreeItem)tmpObj;
                }
                else
                {
                    throw new InvalidOperationException(String.Format("Comparison of '{0}' isn't supported", obj.GetType().ToString()));
                }
            }
        }
        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;
                    }
                }
            }
        }