我有很多 Web 服务方法,我想在一个函数中验证所有这些方法。例如;
[Intercept]
public string Method1(POS pos, int param1, string param2)
{
return String.Format("{0}: {1}", param1,param2);
}
[Intercept]
public int Method2(POS pos, int param3)
{
return param3 * 2;
}
public void OnPreProcessing(...)
{
// Before Mothod1 and Method2 called, It should enter here
// I want to be able to cancel method execution and return another value.
// I want to get the method name, parameter names and values
}
现在我正在使用 ContextBoundObject 和 IMessageSink 来执行此操作。我可以获取方法名称、参数和值,但我无法取消方法执行并返回另一个值。我正在使用类似下面的东西。
public IMessage SyncProcessMessage(IMessage msg)
{
var mcm = msg as IMethodCallMessage;
OnPreProcessing(ref mcm);
var retMsg = _NextSink.SyncProcessMessage(msg) as IMethodReturnMessage;
OnPostProcessing(mcm, ref retMsg);
return retMsg;
}
如何取消方法执行并返回另一个值?
谢谢。