private void AddIdentityConstraints()
{
SchemaElementDecl currentElementDecl = _context.ElementDecl;
_context.Constr = new ConstraintStruct[currentElementDecl.Constraints.Length];
int id = 0;
for (int i = 0; i < currentElementDecl.Constraints.Length; ++i)
{
_context.Constr[id++] = new ConstraintStruct(currentElementDecl.Constraints[i]);
} // foreach constraint /constraintstruct
// added on June 19, make connections between new keyref tables with key/unique tables in stack
// i can't put it in the above loop, coz there will be key on the same level
for (int i = 0; i < _context.Constr.Length; ++i)
{
if (_context.Constr[i].constraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref)
{
bool find = false;
// go upwards checking or only in this level
for (int level = _validationStack.Length - 1; level >= ((_startIDConstraint >= 0) ? _startIDConstraint : _validationStack.Length - 1); level--)
{
// no constraint for this level
if (((ValidationState)(_validationStack[level])).Constr == null)
{
continue;
}
// else
ConstraintStruct[] constraintStructures = ((ValidationState)_validationStack[level]).Constr;
for (int j = 0; j < constraintStructures.Length; ++j)
{
if (constraintStructures[j].constraint.name == _context.Constr[i].constraint.refer)
{
find = true;
if (constraintStructures[j].keyrefTable == null)
{
constraintStructures[j].keyrefTable = new Hashtable();
}
_context.Constr[i].qualifiedTable = constraintStructures[j].keyrefTable;
break;
}
}
if (find)
{
break;
}
}
if (!find)
{
// didn't find connections, throw exceptions
SendValidationEvent(SR.Sch_RefNotInScope, QNameString(_context.LocalName, _context.Namespace));
}
} // finished dealing with keyref
} // end foreach
// initial set
if (_startIDConstraint == -1)
{
_startIDConstraint = _validationStack.Length - 1;
}
}