我有这门课:
class UrlManagementServiceClient : System.ServiceModel.ClientBase<IUrlManagementService>, IUrlManagementService
Run Code Online (Sandbox Code Playgroud)
ClientBase实现IDisposable和ICommunicationObject.我也有这个界面:
interface IUrlManagementProxy : IUrlManagementService, ICommunicationObject, IDisposable
Run Code Online (Sandbox Code Playgroud)
但我无法施放UrlManagementServiceClient物体IUrlManagementProxy.有没有办法实现这个目标?我想最终得到一个可以访问所有三个接口上的所有方法的对象.
您只能转换为您继承的接口,为了能够转换为IUrlManagementProxy您需要实现该接口。
class UrlManagementServiceClient :
System.ServiceModel.ClientBase<IUrlManagementService>, IUrlManagementProxy
Run Code Online (Sandbox Code Playgroud)
然后您可以转换UrlManagementServiceClient为UrlManagementProxy、IUrlManagementService、ICommunicationObject或IDisposable。
编辑
WCF 生成的类是部分的,这意味着您可以在另一个文件中扩展类定义。放
public partial class UrlManagementServiceClient : IUrlManagementProxy {}
Run Code Online (Sandbox Code Playgroud)
在另一个代码文件中,您的类IUrlManagementProxy也将实现您的完整接口,然后您可以将其转换为IUrlManagementProxy.
| 归档时间: |
|
| 查看次数: |
1478 次 |
| 最近记录: |