I have a basic c# app to process some sql files. I have a class for each type of object like proc, function, view, etc.
What I want to do in the main is determine what kind of script file im processing and them create an instance of that class.
Then using that object, call it objSqlType, I want to call a method in the underlying class. each class will have the same method names implemented like getHeader(), getPermissions(), etc
Is this possible. I looked at interfaces which forces me to create methods but can't seem to use a single object,
for example:
object objSqlType;
switch (type)
{
case ObjectType.PROC:
objSqlType = new SqlProc();
break;
case ObjectType.FUNCTION:
objSqlType = new SqlFunction();
break;
case ObjectType.VIEW:
objSqlType = new SqlView();
break;
default:
break;
}
string header = objSqlType.getHeader(); // call getHeader for whichever object I created