开发者

Extension methods in a data contract

开发者 https://www.devze.com 2023-02-27 08:26 出处:网络
Can we two WCF services where one service contract derives from another and have an extensionmethod inside the derived contract. what will be the result of accessing this contract from the WCF Client.

Can we two WCF services where one service contract derives from another and have an extension method inside the derived contract. what will be the result of accessing this contract from the WCF Client. I.e. what will happen if IDServiceis accessed E.g.

[ServiceContract]
public开发者_开发百科 interface IBaseService
{
  public void A();
  ...
}

[ServiceContract]
public interface IDService: IBaseService
{
  public static void B(this IBaseService S);
  ....
}


You can't define static methods in an interface (nor the access modifier public which you've specified above either).


A good question - got me to a lot of head scratching.

Extension method is meaningless to WCF - and WSDL for that matter.

If you use Service Reference to generated the client, you would not see the extension method (since WSDL would not know anything about the extension method) so you cannot use it.

If you use DLL/Project reference, your code will be called locally and not through the proxy.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号