简体   繁体   English

wcf休息入门套件2

[英]wcf rest starter kit 2

使用其余集合模板时,如何修改帮助页面中每个项目的描述?

When you use the template it gives you access to the file Service.svc.cs right inside your project, and you'll see the class inside that file inherits from CollectionServiceBase<TItem>. 当使用模板时,它使您可以直接在项目内部访问文件Service.svc.cs,并且您会看到该文件中的类继承自CollectionServiceBase <TItem>。 You need to modify that class in order to change the descriptions in the help page. 您需要修改该类才能更改帮助页面中的描述。 Unfortunately CollectionServiceBase<TItem> is already pre-built for you and it's part of the binary Microsoft.ServiceModel.Web.dll, so you can't edit it from VS. 不幸的是CollectionServiceBase <TItem>已经为您预先构建,并且它是二进制Microsoft.ServiceModel.Web.dll的一部分,因此您不能从VS中对其进行编辑。

The way to work around this is to crack open the source code of the starter kit (zipped up at %ProgramFiles%\\Microsoft WCF REST\\WCF REST Starter Kit Preview 2) and hunt for the file CollectionServiceBase.cs, where the type CollectionServiceBase<TItem> is defined. 解决此问题的方法是打开入门工具包的源代码(在%ProgramFiles%\\ Microsoft WCF REST \\ WCF REST入门工具包预览2中压缩),并搜索文件CollectionServiceBase.cs,其中类型为CollectionServiceBase <定义了TItem>。 You then need to copy that file to your solution (so you can modify it) and make sure it is referenced from Service.svc.cs. 然后,您需要将该文件复制到解决方案中(以便可以对其进行修改),并确保已从Service.svc.cs中引用了该文件。

In CollectionServiceBase<TItem> itself, look for the [WebHelp] attruibute and you'll be able to edit the descriptions on that attribute. 在CollectionServiceBase <TItem>本身中,查找[WebHelp]属性,然后就可以编辑该属性的描述。

Excellent answer - thanks, Yavor. 很好的答案-谢谢,雅沃。

That also answers the question I have been struggling with - how to add methods to a web service based on a Starter Kit template. 这也回答了我一直在努力的问题-如何基于Starter Kit模板向Web服务添加方法。 We simply have to edit our copy of the CollectionServiceBase.cs file. 我们只需要编辑CollectionServiceBase.cs文件的副本即可。

Note: On adding the CollectionServiceBase.cs copy to my solution, I received warnings about potential conflict vs the originally imported version. 注意:在将CollectionServiceBase.cs副本添加到我的解决方案中时,我收到了有关与原始导入版本潜在冲突的警告。 I resolved this by renaming my version (and the links to it). 我通过重命名我的版本(及其链接)来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM