I have a slight problem in my code here I think is interesting:
foreach(ISceneNode node in (root as IGroupNode))
{
PreVisit(node);
if (notFound == false)
{
return node;
}
else
PostVisit(node);
}
I'm trying to call the methods PreVisit and PostVisit on the ISceneNode object node, which is a parent class to other types of nodes. However, because this is "too general" of an object relationship, I am not allowed to call the methods:
//methods
void PreVisit(IDrawableNode drawable)
{
string targetName = drawable.Name;
Boolean notFound = true;
CompareToTarget(targetName, notFound, drawable);
}
void PreVisit(ITransformNode transform)
{
string targetName = transform.Name;
Boolean notFound = true;
CompareToTarget(targetName, notFound, transform);
}
void PreVisit(IStateNode state)
{
string targetName = state.Name;
Boolean notFound = true;
CompareToTarget(targetName, notFound, state);
}
void PreVisit(IGroupNode group)
{
string targetName = group.Name;
Boolean notFound = true;
CompareToTarget(targetName, notFound, group);
}
The IGroupNode, IStateNode, etc derive from the ISceneNode... so why can't I call this overloaded method using just an ISceneNode? Is it because it doesn't know which method to select? How can I account for this in my code and workaround it?