通过反射自动生成WCF服务。
我们目前正在编写一个后端系统,并计划通过WCF提供一层方法。是否有任何工具或开源库可以通过读取属性(例如 [WCFEnabled])进行反射,使方法可以通过特定的 WCF 通道可用?
例如,想象一个 WCF 服务 ItemService。在 Item 类中,有一个名为“AddItem”的方法。添加 [WCFEnabled] 后,该方法将可通过 ItemService 进行编译。
We are currently writing a back-end system, and plan on providing a layer of methods through WCF. Is there any tool out there, or open source library that through reflection by reading attributes, for instance [WCFEnabled], would make the methods available through a particular WCF Channel available?
For instance, imagine a WCF service, ItemService. In the Item class, there would be a method named "AddItem". On adding [WCFEnabled], that method would be available on compilation through the ItemService.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯。
[操作合同]
?但是,不确定这些是否适用于类方法,通常它们被放在接口方法上,并且您的类实现了该接口。
Erm.
[OperationContract]
?However, not sure if these will work on a class methods, normally they're put on interface methods and your class implements the interface.
我们通过使用 T4 模板来构建服务接口、实现和客户端代理做了类似的事情。
T4 模板解析服务项目并提取用自定义属性修饰的所有方法。然后,它为它发现的每个服务构建带有实现类/接口的 svc 文件。它还创建客户端代理。
We have done something similar by using T4 templates to build the service interfaces, implementations and client proxies.
The T4 template parses a Service Project and extracts all methods that are decorated with a custom attribute. Then it builds svc files with an implemenation class/interface for each service it discovers. It also creates the client proxies.