I have a class hierarchy as such:
+
|
INode
| |
+
|
+
And the corresponding class NodeCollectionbuilt on INode. To display, NodeCollectionI need to know the final type of each member. Therefore, I need such a function
foreach (INode n in myNodeCollection)
{
switch(n.GetType())
{
case(typeof(SiteNode)):
}
}
Now this is really not an object oriented way to do this. Are there any patterns or recommended ways to do the same in your opinion?
EDIT
I was already thinking of adding a method to Displayeither Renderthe INode interface. This has a side effect associated with the presentation of the model that I really would like to avoid.
source
share