使用 WCF 操作合同获取当前的 WCF 行为并根据当前行为做一些事情是一个好主意吗?如果没有:为什么不呢?如果是:我该怎么做?
例如这样的:
// Interface
[ServiceContract]
public interface IDataService
{
[OperationContract]
DataResponse GetData(DataRequest request);
}
// Implementation of the IDataService.GetData
public DataResponse GetData(DataRequest request)
{
// get current behavior
IBehavior currBevhavior = ...?
if (currBehavior.name = ""){
// custom code for this behavior
}
...
}
编辑:绑定同样的事情:根据当前请求的绑定在代码中做一些事情是个好主意吗?我怎样才能做到这一点?