我有几个 WCF 服务合同,所有这些合同都包含完全相同的方法StopOperation
,具有相同的签名:
[ServiceContract]
public interface IMyServiceA
{
[FaultContract(typeof(ServiceAError))]
[OperationContract]
void StopOperation(TaskInformation taskInfo);
// other specific methods
}
我希望能够做的是提取StopOperation
到一个接口中IStoppable
,并让我的所有服务都继承这个操作。但是,我对FaultContract
定义有疑问,因为它定义了具体的故障类型。
是否FaultContract
可以引用抽象ErrorBase
类型,并以某种方式指定具体类型KnownContract
?有一些像:
[ServiceContract]
public interface IStoppable
{
[FaultContract(typeof(ErrorBase))]
[OperationContract]
void StopOperation(TaskInformation taskInfo);
}
无论我在哪里尝试指定KnownContract
,它似乎都没有。