Manipulate method functionality call
- by danrichardson
Hello, is it possibly in c# to have some sort of base class functionality which is manipulated slightly based on the class. For instance say i have the following code (which will quite obviously not compile it's meant to only be for demonstrative purposes)
class BaseFunctionality
{
public virtual bool adminCall
public static string MethodName(int id, string parameter)
{
if (adminCall)
return dbcall.Execute();
else
return dbcall.ExecuteMe();
}
}
class Admin : BaseFunctionality
{
override bool adminCall = true;
}
class Front : BaseFunctionality
{
override bool adminCall = false;
}
Now what i would like to be able to do is;
string AdminCall = Admin.MethodName(1, "foo");
string FrontCall = Front.MethodName(2, "bar");
Is their any way to do something like this? I'm trying to do everything with static methods so i do not have to instantiate classes all the time, and have nice clean code which is only being manipulated in one place.
The idea behind this is so that there is minimal code repeating and makes things easier to expand on, so for instance another class could implement the BaseFunctionality later on.
Thanks
Dan