问题是在 AfterReceiveRequest 如何使用 OperationDescription 找出操作上设置的自定义属性?如果有办法,在服务契约接口或服务实现类中的操作声明上设置自定义属性更好吗?
为了进一步说明问题:
public interface IGetterSetterService
{
[OperationContract, GetterRequest]
Data[] GetData();
[OperationContract, SetterRequest]
bool SetData(string Data);
}
或者
[WebInvoke(Method = "*", ResponseFormat = WebMessageFormat.Json, UriTemplate = "xyz"]
[GetterRequest]
public Data[] GetData()
{
return new Data[];
}
[WebInvoke(Method = "*", ResponseFormat = WebMessageformat.Json, UriTemplate = "xyz/{data}"]
[SetterRequest]
public bool SetData(string data)
{
return true;
}
现在是 IDispatchMessageInspector:
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
{
//Here how to find out the GetterRequest or SetterRequest custom attribute set on an
//operation, may be using OperationDescription for the current context?
}