ServiceStack IReturn [英] ServiceStack IReturn

查看:220
本文介绍了ServiceStack IReturn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待在新的API,就出来了2个星期前。这似乎是

I am looking at the new api that came out 2 weeks ago. It seems like

ReqDTO : IReturn<List<ResDTO>> { //... }

在IReturn位似乎是可选的?该DTO的在RazorRockstars示范项目工作离不开它。

The "IReturn" bit seems to be optional? The DTOs in RazorRockstars demo project works without it.

推荐答案

这是一个新增加的 ServiceStack的新API 它可以让你记录了预期的响应类型的请求DTO将返回,如与

This is a new addition in ServiceStack's New API which allows you to document the expected Response Type that the Request DTO will return, e.g. with

ReqDTO : IReturn<List<ResDTO>> { ... }

它允许您调用任何使用C#的客户服务与

Which lets you call using any of the C# Service Clients with:

List<ResDTO> response = client.Get(new ReqDto());

如果你没有足够的IReturn标记您的客户端调用必须是这样的:

If you didn't have the IReturn marker your client call would have to look like:

List<ResDTO> response = client.Get<List<ResDTO>>(new ReqDto());

这是后话了客户/消费者的服务需要了解。如果你有标记的DTO的响应类型是已知的。

Which is something the client/consumer of your service needs to know about. If you had the marker on the DTO the response type is already known.

IReturn&LT;&GT; 标记也被用来确定这是我们用来在HTTP响应中ServiceStack的响应DTO /元页。

The IReturn<> marker is also used to determine the Response DTO that's used in the HTTP Responses in ServiceStack's /metadata pages.

这篇关于ServiceStack IReturn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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