public void HandleRpc(ISender caller, String method, IList arguments,
object request_state) {
object result = new InvalidOperationException("Invalid method");
if(method.Equals("Enable") || method.Equals("Disable")) {
if(arguments.Count < 2) {
Rpc.SendResult(request_state, new Exception("Not enough arguments."));
return;
}
string option_type = arguments[0] as string;
string option_name = arguments[1] as string;
if(option_type == null || option_name == null) {
Rpc.SendResult(request_state, new Exception("Expected a string."));
return;
}
if(option_type.Equals("BooleanSwitch")) {
BooleanSwitch bs;
if(!TryGetBooleanSwitch(option_name, out bs)) {
Rpc.SendResult(request_state, new Exception("No such BooleanSwitch."));
return;
}
bs.Enabled = method.Equals("Enable");
result = true;
} else if(option_type.Equals("Trace") && option_name.Equals("Console")) {
if(method.Equals("Enable")) {
Trace.Listeners.Add(Console);
} else {
Trace.Listeners.Remove(Console);
}
result = true;
} else {
result = new InvalidOperationException("Invalid method");
}
}
Rpc.SendResult(request_state, result);
}