private object TraceOperation(DocTemplateDefinition template, DocOp op, StringBuilder sb, SEntity ent, List<SEntity> population, int level)
{
System.Collections.Hashtable hashtable = new System.Collections.Hashtable();
object result = op.Eval(ent, hashtable, template, null, null);
if (hashtable.Count > 0)
{
// must evaluate all for uniqueness
foreach (object other in population)
{
if (other == ent) // first instance will pass; following duplicate instances will fail
break;
// returning false means there's a duplicate (not unique).
object otherresult = op.Eval(other, hashtable, template, null, null);
if (otherresult is bool && !(bool)otherresult)
{
result = false;
break;
}
}
}
if (result is bool && !((bool)result))
{
for (int i = 0; i < level; i++ )
{
sb.Append(" ");
}
sb.AppendLine(op.ToString(template) + "<br/>");
}
// recurse
if (op is DocOpLogical)
{
DocOpLogical oplog = (DocOpLogical)op;
TraceOperation(template, oplog.ExpressionA, sb, ent, population, level + 1);
TraceOperation(template, oplog.ExpressionB, sb, ent, population, level + 1);
}
return result;
}