RestSharp 诉 WebClient?

发布于 2024-09-29 03:55:18 字数 118 浏览 6 评论 0原文

我正在构建一个 Windows Phone 7 Silverlight 应用程序。有什么理由使用 RestSharp 而不是 WebClient 吗?我浏览过 RestSharp 网站,但并没有立即明显看出它的好处是什么。

I'm building a Windows Phone 7 Silverlight app. Is there any reason to use RestSharp instead of WebClient? I've looked around on the RestSharp site, but it's not immediately obvious what the benefits are.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三寸金莲 2024-10-06 03:55:18

RestSharp 消除了以下痛点:

  • .NET 的 HTTP 类中的怪癖(基本身份验证被破坏、非 200 响应的错误处理等)
  • 从响应数据到 POCO 的自动反序列化
  • 简化的 API (request.AddParameter(name, value) 而不是手动编译请求体
  • 简化请求/响应语义,特别是对于异步(但是,它对于异步是固执己见,可能无法满足每个人的需求,在这种情况下我还建议评估 Hammock)

反序列化可能是最大的收获,因为对于大多数 API,您无需做太多工作即可将 XML 或 JSON 放入 C# 对象中。

我会查看这些页面以获取更多信息

https://github.com/restsharp/RestSharp/wiki
https://github.com/restsharp/RestSharp/wiki/ RestSharp-Blog-Posts-and-Links

欢迎在此或在 Google 上发布任何问题组

RestSharp removes the following pain points:

  • Quirks in .NET's HTTP classes (basic authentication is broken, error handling for non-200 responses, etc)
  • Automatic deserialization from response data to POCOs
  • Simplified API (request.AddParameter(name, value) instead of manually compiling request bodies
  • Simplified request/response semantics, especially for async (however, it's opinionated for async and may not meet everyone's needs, in which case I would also suggest evaluating Hammock)

Deserialization is probably the biggest gain since for most APIs you don't have to do very much to get the XML or JSON into your C# objects.

I would check out these pages for more info

https://github.com/restsharp/RestSharp/wiki
https://github.com/restsharp/RestSharp/wiki/RestSharp-Blog-Posts-and-Links

Feel free to post any questions here or on the Google Group

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文