private static CheckResult ReferenceVerificationHelper(IElement element, ref string cycleString, Stack<IElement> visitedElements)
{
List<string> typesReferenced = new List<string>();
//Assign the current VerificationId to identify nodes that have been visited
((INamedObjectContainer)element).VerificationIndex = VerificationId;
if (visitedElements.Contains(element))
{
cycleString += "The type " + element + " causes a circular reference";
return CheckResult.Failed;
}
else
{
visitedElements.Push(element);
foreach (NamedObjectSave namedObject in element.NamedObjects)
{
if ((!namedObject.SetByContainer && !namedObject.SetByDerived) &&
namedObject.SourceType == SourceType.Entity)
{
EntitySave nosEntity = ObjectFinder.Self.GetEntitySave(namedObject.SourceClassType);
if (nosEntity != null)
{
CheckResult returnValue = ReferenceVerificationHelper(nosEntity, ref cycleString, visitedElements);
if (returnValue == CheckResult.Failed)
{
return CheckResult.Failed;
}
}
}
}
visitedElements.Pop();
return CheckResult.Passed;
}
}