public bool IsEncodingOf(ExpandedNodeId encodingId, ExpandedNodeId datatypeId)
{
// check for invalid ids.
if (NodeId.IsNull(encodingId) || NodeId.IsNull(datatypeId))
{
return false;
}
NodeId localId = ExpandedNodeId.ToNodeId(encodingId, m_namespaceUris);
if (localId == null)
{
return false;
}
NodeId localTypeId = ExpandedNodeId.ToNodeId(datatypeId, m_namespaceUris);
if (localTypeId == null)
{
return false;
}
lock (m_lock)
{
// lookup the immediate basetype of the subtype.
TypeInfo typeInfo = null;
if (!m_encodings.TryGetValue(localId, out typeInfo))
{
return false;
}
// the encoding is a representation of the expected datatype id.
if (localTypeId == typeInfo.NodeId)
{
return true;
}
// check if the encoding is a representation of a subtype of the expected datatype id.
TypeInfo superTypeInfo = typeInfo.SuperType;
while (superTypeInfo != null)
{
if (!superTypeInfo.Deleted && superTypeInfo.NodeId == localTypeId)
{
return true;
}
superTypeInfo = superTypeInfo.SuperType;
}
// no match.
return false;
}
}