I need to know an efficient way to handle one object at the time to control one of this 3 classes without the switch. (Knowing the object type at any point)
Note : The method AddVertex is not overloaded, so its common to the parent class.
switch (User.Action)
{
case Actions.NewVertex:
switch (GraphsType)
{
case GraphsType.None:
Graph.AddVertex(p); /*This is the parent class*/
break;
case GraphsType.UndirectedGraph:
UndirectedGraph.AddVertex(p); /*This is a derived class*/
break;
case GraphsType.DirectedGraph:
DirectedGraph.AddVertex(p); /*This is a derived class,*/
break;
}
}