【发布时间】:2015-06-12 16:48:15
【问题描述】:
我有许多 WCF 服务,它们都有特定的方法 ServicePing,它返回有关服务的一些信息。我希望能够将此方法抽象为一个接口,以便我可以在客户端中使用它。
我去了第一个服务并将ServicePing方法移到IPingable接口中。然后我使现有接口继承自IPingable。当我更新服务并重新生成代理时,我可以看到方法,但是代理类本身并没有实现IPingable,虽然那是调用的位置。
然后我回到服务,我没有让接口继承IPingable,而是让服务本身实现了这两个接口。现在我什至看不到生成的类中的方法。
如果没有办法让两个接口都通过客户端,那么我正在考虑添加到生成的Partial Class。类似的东西
Partial Public Class GeneratedClass
Implements IGeneratedClassContract
Public Function ServicePing() As Boolean Implements IGeneratedClassContract.ServicePing
'Definition
添加这个:
Partial Public Class GeneratedClass
Implements IPingable
Public Function ServicePing() As Boolean Implements IPingable.ServicePing
`Call IGeneratedClassContract.ServicePing
有没有办法更新现有调用以实现另一个(完全相同)方法?当您无法更新定义时,这是获得实现两个接口的单一方法的最佳方式吗?
【问题讨论】: