什么决定了WCF Test Client中方法的顺序? [英] What determines the order of methods in WCF Test Client?

查看:56
本文介绍了什么决定了WCF Test Client中方法的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WCF测试客户端似乎没有以任何逻辑顺序放置方法.但是,顺序是一致的.在每种环境下,它都保持不变.

WCF Test Client doesn't seem to put methods in any logical order. However, the order is consistent. It remains the same in every environment.

这不是字母顺序的.这不是类中方法的顺序.WCF Test Client中的顺序与WSDL中的顺序不匹配.

It's not alphabetical. It's not the order of the methods in the class. The order in WCF Test Client does not match the order in the WSDL.

虽然不是完全随机的.有时的顺序与该类匹配.但是然后您可以在类中更改顺序,重新编译,然后将服务添加回WCF Test Client时,它不会更改为匹配.

It's not totally random though. The order sometimes matches up with the class. But you can then change around the order in the class, re-compile, and when you add the service back to WCF Test Client, it doesn't change to match.

那确定订单的是什么?

推荐答案

出于好奇,我查看了WcfClientTest.exe源代码以了解顺序.

For the sake of curiosity, I had a look at WcfClientTest.exe source code to find out what the order is.

下面的代码可能是填充所有方法的地方(免责声明:我只是猜测!没有时间来验证这一点):

The following piece of code is probably where all the methods are populated (disclaimer: I just guessed! No time to verify this):

endpoint.ClientTypeName = GetContractTypeName(contractType);
foreach (MethodInfo info in contractType.GetMethods())
{

那么GetMethods返回的方法的顺序是什么?根据此MSDN链接: https://msdn.microsoft.com/en-us/library/4d848zkb(v=vs.110).aspx

So what is the order of the methods which GetMethods returns? According to this MSDN link: https://msdn.microsoft.com/en-us/library/4d848zkb(v=vs.110).aspx

GetMethods方法不会以特定顺序返回方法,例如字母顺序或声明顺序.您的代码不得依赖返回方法的顺序,因为顺序会有所不同.

The GetMethods method does not return methods in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which methods are returned, because that order varies.

这就是我能找到的全部:)

That's all I can find out :)

这篇关于什么决定了WCF Test Client中方法的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆