private bool VerifyReferenceTypeId(Node node, BrowseDescription description, ReferenceDescription reference)
{
// check if field was not requested.
if ((description.ResultMask & (uint)BrowseResultMask.ReferenceTypeId) == 0)
{
if (!NodeId.IsNull(reference.ReferenceTypeId))
{
Log("Returned unexpected non-null ReferenceTypeId when Browsing Node '{0}'. NodeId = {1}", node, node.NodeId);
return false;
}
return true;
}
// check for null.
if (NodeId.IsNull(reference.ReferenceTypeId))
{
Log("Returned unexpected null ReferenceTypeId when Browsing Node '{0}'. NodeId = {1}", node, node.NodeId);
return false;
}
// check for valid reference.
IReferenceType referenceType = Session.NodeCache.Find(reference.ReferenceTypeId) as IReferenceType;
if (NodeId.IsNull(reference.ReferenceTypeId))
{
Log("Returned invalid ReferenceTypeId when Browsing Node '{0}'. NodeId = {1}, ReferenceTypeId = {2}", node, node.NodeId, reference.ReferenceTypeId);
return false;
}
// check for valid subtype.
if (!Session.TypeTree.IsTypeOf(referenceType.NodeId, description.ReferenceTypeId))
{
string expectedName = description.ReferenceTypeId.ToString();
IReferenceType expectedType = Session.NodeCache.Find(description.ReferenceTypeId) as IReferenceType;
if (expectedType != null)
{
expectedName = Utils.Format("{0}", expectedType.DisplayName);
}
Log("ReferenceType {2} is not a subtype of {3} when browsing Node '{0}'. NodeId = {1}", node, node.NodeId, referenceType.DisplayName, expectedName);
return false;
}
return true;
}