You could make a Dictionary<MyEnum, Object>
;. After you extract the value, cast it to the appropriate delegate and invoke it.
Alternately, you could use something like the command pattern, and pass in commands rather than enumerated values:
interface ICommand
{
void Execute();
}
class SomeCommand : ICommand
{
public SomeCommand(/* instance and parameters go here */) { /* ... */ }
public void Execute() { /* ... */ }
}
class SomeOtherCommand : ICommand { /* ... */ }
If you want them to be accessible like an enum, you could make a factory class w/ static methods to create your specific commands:
class RemoteCommand
{
public static SomeCommand SomeCommand
{
get
{
var result = new SomeCommand(/* ... */);
// ...
return result;
}
}
public static SomeOtherCommand SomeOtherCommand { get { /* ... */ } }
}
Edit:
Also, not sure of your needs, but exposing a list of method calls that the user might want to make, but abstracting out exactly what gets called sure sounds like an interface:
interface IRemoteCommand
{
void RemoteMethod();
void OtherRemoteMethod(/* params */);
void ImplementedAgainstADifferentServerMethod();
}