0

Webサービスメソッドがたくさんあり、それらすべてを1つの関数で検証したいと思います。例えば;

[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;
}

メソッドの実行をキャンセルして別の値を返すにはどうすればよいですか?

ありがとう。

4

1 に答える 1