问题描述
所以.NET 4中添加了一个名为和可选参数,这些参数pretty的甜蜜。我并不需要做尽可能多的1线路的过载的方法。
so .Net 4 added named and optional parameters which are pretty sweet. I don't need to make as many 1 line overload methods.
请问这项工作在WCF?
Will that work over WCF?
推荐答案
由于这些是编译器的语义我会说不。但是你会期待他们的唯一方式如下工作。
Since these are compiler semantics I'd say no. However you'd expect them to work in the only following way.
在服务code端的所有code将接受违约的参数。
On the Service Code side all code would accept the defaulted parameters.
在客户端我注意到,添加服务引用工具VS2010上没有采用默认值,并将其添加到生成的代理。所以你必须生成你自己的代理。
On the client side I note that the 'Add Service Reference' tooling on VS2010 doesn't take the defaults and add them to the generated proxy. So You'd have to generate you're own proxy.
在这样的客户端code可以使用默认值,如果默认是在客户端执行的合同规定。
In this way the client code can use the defaults if the the default is specified in the client side contract implementation.
我会,同样是如此命名参数。
I would be that the same is true for the named parameters.
一切的一切,是的,但东西是不结转WCF。所有这一切发生的是,客户端代理将不得不送入通道工厂作为一个适当的参数。
All in all yes, but the stuff is not carried over WCF. All that happens is that the client proxy will have to send into the channel factory as a proper parameter.
这篇关于命名和可选参数,和WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!