Exemple #1
0
        protected bool EqualsCUDResult(CUDResultDiff cudResultDiff)
        {
            ICUDResult     left      = cudResultDiff.left;
            ICUDResult     right     = cudResultDiff.right;
            IList <Object> leftRefs  = left.GetOriginalRefs();
            IList <Object> rightRefs = right.GetOriginalRefs();

            if (leftRefs.Count != rightRefs.Count)
            {
                if (!cudResultDiff.doFullDiff)
                {
                    return(false);
                }
            }
            IList <IChangeContainer>       leftChanges  = left.AllChanges;
            IList <IChangeContainer>       rightChanges = right.AllChanges;
            IdentityHashMap <Object, int?> rightMap     = IdentityHashMap <Object, int?> .Create(rightRefs.Count);

            for (int a = rightRefs.Count; a-- > 0;)
            {
                rightMap.Put(rightRefs[a], a);
            }
            for (int a = leftRefs.Count; a-- > 0;)
            {
                Object leftEntity = leftRefs[a];
                int?   rightIndex = rightMap.Remove(leftEntity);
                if (!rightIndex.HasValue)
                {
                    if (!cudResultDiff.doFullDiff)
                    {
                        return(false);
                    }
                    cudResultDiff.diffChanges.Add(leftChanges[a]);
                    cudResultDiff.originalRefs.Add(leftEntity);
                    continue;
                }
                if (!EqualsChangeContainer(cudResultDiff, leftChanges[a], rightChanges[rightIndex.Value]))
                {
                    if (!cudResultDiff.doFullDiff)
                    {
                        if (cudResultDiff.containerBuild != null)
                        {
                            throw new Exception();
                        }
                        return(false);
                    }
                    cudResultDiff.diffChanges.Add(cudResultDiff.containerBuild);
                    cudResultDiff.originalRefs.Add(rightRefs[rightIndex.Value]);
                    cudResultDiff.containerBuild = null;
                }
                else if (cudResultDiff.containerBuild != null)
                {
                    throw new Exception();
                }
            }
            if (rightMap.Count == 0)
            {
                return(true);
            }
            foreach (Entry <Object, int> entry in rightMap)
            {
                Object           rightRef    = entry.Key;
                int              rightIndex  = entry.Value;
                IChangeContainer rightChange = rightChanges[rightIndex];
                cudResultDiff.diffChanges.Add(rightChange);
                cudResultDiff.originalRefs.Add(rightRef);
            }
            return(false);
        }