Help with classnode


I am using a modified version of ClassDiagramNode and would like to know how do use Document.Findnode to determine if a ClassDiagramNodeItem already exists in all ClassDiagramNodes. currently using this code but it always returns null

string callingaddress = read from database;

if (goView1.Document.FindNode(callingaddress, false, true, true) == null)

{

ilist.List.Add(unknown.MakeItem(image, callingaddress));

}

what i would like to know does the findnode method search for these items or skips it?

No. Findnode will search inside GoSubGraphBase items, but ClassDiagramNode is based on GoBoxNode.

so i have to write a recursive method and search all goobjects tried the following but want to make it work for miltiple nodes

private bool findnode(ClassDiagramNodeItemList classdnilist, string text)

{

bool result = false;

foreach (ClassDiagramNodeItem i in classdnilist.List)

{

if (i.Text == text)

{

result = true;

return result;

}

}

this worked but i need it for all classnodediagrams so came up with the following code

foreach (GoObject o in goView1.Document)

{

if (o is ClassDiagramNodeItem)

{

ClassDiagramNodeItem a = (ClassDiagramNodeItem)o;





if (a.Text == text)

{

result = true;

return result;

}





}

}



this results in too many duplicates

thanks

foreach (GoObject o in goView1.Document)



is just going to iterate the toplevel objects in the document, not every part within the nodes. You’re going to have to write code that walks the ClassDiagramNodeItem list inside a foreach of the GoDocument. (or search recursively if you have more than 1 level)



Given you can probably have 2 ClassNodes with “attribute1”, you may need to get a little fancier with your naming scheme (e.g. ClassA.attribute1 and ClassB.attribute1)