Wcf服务代理名称/命名空间命名策略 [英] Wcf Service Proxy Name / Namespace naming strategy
问题描述
任何人都有一个命名策略,适用于服务代理类?
Anyone have a naming strategy that works well for service proxy classes?
例如,如果我在两个项目中提供了三个Web服务, >
For example, if I am given three web services within two projects as follows:
XWs
AService.asmx
YWs
BService.svc
CService.svc
用作服务引用名称& AService
, BService
和的命名空间
What would use as the Service Reference Name & Namespace for AService
, BService
and CService
?
一般来说,我想在代理名称/命名空间中指明所使用的东西不是一个具体的类,而是代表一个代理 - 因此它不会与使用具体类[和强制使用别名或命名空间限定类名],所以我们不会隐藏的事实,有一个跳跃发生(我猜Wcf服务代理生成器的默认后缀的客户端覆盖)。同样重要的是,它处理的情况下,一个正在写一个包装器/垫片服务,转发一个[子]集调用到另一个引用的服务。
In general, I'd like something in the proxy name/namespace to indicate that the thing being used is not a concrete class, but represents a proxy - both so it doesnt clash with usage of concrete classes [and force usage of aliasing or namespace-qualified class names], and so we're not hiding the fact that there's a hop happening (I guess the Wcf Service Proxy generator's default suffix of Client covers that). Also important is that it deals with cases where one is writing a wrapper/shim service that is forwarding a [sub]set of calls to another referenced service.
使用各种样式(添加 Ws
, ServiceProxy
, Ref
代理
后缀?前缀为 ServiceName。
),但从未完全满意。
I've used various styles (Adding Ws
, ServiceProxy
, Ref
or Proxy
suffixes? Prefixing with ServiceName.
), but have never been fully happy with them.
有什么对你有好处?
编辑:虽然Cheeso的答案涵盖了我的大部分问题,我仍然有兴趣听取以下方面的答案:
While Cheeso's answer covers the bulk of my question, I'm still interested in hearing answers on:
- 如上例所示的命名空间代理类的策略
- 一种风格指南,代理
推荐答案
我最初使用的名称如ServiceName Proxy < SvcProxy 。但是,和你一样,我对这些名字并不特别满意,因此我没有坚持这些名字。现在我只是使用ServiceName 服务或ServiceName Svc 。
I originally used names like ServiceNameProxy and ServiceNameSvcProxy. But, like you, I haven't been particularly satisfied with those names, and as a result I did not stick with them. Now I just resort to ServiceNameService or ServiceNameSvc.
该类是代理的类的 ?你所做的 - 代理类和具体类之间的区别 - 似乎适用和短吻鳄。相反的具体是抽象的,没有?而由svcutil.exe生成的代理类实际上是具体的。
Is the key thing you want to communicate to users of the class that the class is a proxy? The distinction you are making - between a proxy class and a concrete class - seems like applies and alligators. The opposite of concrete is abstract, no? And the proxy class generated by svcutil.exe is, in fact, concrete.
有了命名约定,我想你试图表明代理类与远程服务通信。 (当我们称之为代理,我们意味着它站在一些东西,在这种情况下是远程服务)。如果是这样,那么为什么不ServiceName Service 或ServiceName 连接,或类似?像System.Data.OleDb.OleDbConnection或System.Data.SqlClient.SqlConnection。
With a naming convention, I think you are trying to indicate that the proxy class communicates to a remote service. (When we call it a "proxy", we mean to indicate it stands in front of something, in this case the remote service. ) If that is the case, then why not ServiceNameService or ServiceNameConnection, or along similar lines? Like System.Data.OleDb.OleDbConnection or System.Data.SqlClient.SqlConnection.
我自己选择的命名约定是符合的。它表示该类表示一个服务,它被假定为远程的。我不在乎这么多,强调它是一个代理服务。出于实际目的,它是一个服务的事实是关键的事情。
My own chosen naming convention is in line with that. It indicates that the class represents a service, which is assumed to be remote. I don't care so much to accentuate the fact that it is a proxy-to-a-service. For practical purposes the fact that it is a Service is the key thing.
这篇关于Wcf服务代理名称/命名空间命名策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!