private static BigInteger HashReference(IModelElement modelElement, IReference reference, Model containingModel, Func <IModelElement, Model, BigInteger> computeElementHash) { var hash = new BigInteger(GetDeterministicHashCode(reference.Name)); if (reference.UpperBound == 1) { var value = modelElement.GetReferencedElement(reference); if (value != null) { hash += computeElementHash(value, containingModel); } } else { var collection = modelElement.GetReferencedElements(reference); if (collection != null) { var index = 0; foreach (IModelElement item in collection) { hash += index + computeElementHash(item, containingModel); if (reference.IsOrdered) { index++; } } } } return(hash); }
private void PerformChecksForModelElement(NMF.Models.Meta.IReference reference, IModelElement element, IModelElement other) { if (reference.IsContainment) { AssertAreEqual(element, other.Parent); } if (reference.Opposite != null) { if (reference.Opposite.UpperBound == 1) { AssertAreEqual(element, other.GetReferencedElement(reference.Opposite)); } else { AssertIsTrue(other.GetReferencedElements(reference.Opposite).Cast <IModelElement>().Contains(element)); } } }