private void BuildDeclarationList(DeclarationNode parent, List<DeclarationNode> declarations)
{
if (parent == null) throw new ArgumentNullException("parent");
if (declarations == null) throw new ArgumentNullException("declarations");
// get list of children.
IList<IReference> references = parent.Node.References.Find(ReferenceTypeIds.HierarchicalReferences, false, true, m_nodes.TypeTree);
foreach (IReference reference in references)
{
// do not follow sub-type references.
if (m_nodes.TypeTree.IsTypeOf(reference.ReferenceTypeId, ReferenceTypeIds.HasSubtype))
{
continue;
}
// find child (ignore children that are not in the node table).
ILocalNode child = GetLocalNode(reference.TargetId) as ILocalNode;
if (child == null)
{
continue;
}
// create the declartion node.
DeclarationNode declaration = new DeclarationNode();
declaration.Node = child;
declaration.BrowsePath = Utils.Format("{0}.{1}", parent.BrowsePath, child.BrowseName);
declarations.Add(declaration);
// recursively include aggregated children.
NodeId modellingRule = child.ModellingRule;
if (modellingRule == Objects.ModellingRule_Mandatory || modellingRule == Objects.ModellingRule_Optional)
{
BuildDeclarationList(declaration, declarations);
}
}
}