private bool FindInstanceDeclarationsInType(
ExpandedNodeId instanceId,
List<QualifiedName> browsePath,
int index,
List<ILocalNode> declarations)
{
// ignore remote nodes.
ILocalNode instance = GetLocalNode(instanceId) as ILocalNode;
if (instance == null)
{
return false;
}
// nothing more to do if no match on current browse name.
if (instance.BrowseName != browsePath[index])
{
return false;
}
// add match to list of declarations.
if (index >= browsePath.Count-1)
{
declarations.Add(instance);
return true;
}
// recursivily find chilren.
IList<IReference> children = instance.References.Find(ReferenceTypeIds.HierarchicalReferences, false, true, m_server.TypeTree);
foreach (IReference reference in children)
{
if (FindInstanceDeclarationsInType(reference.TargetId, browsePath, index+1, declarations))
{
return true;
}
}
return false;
}