Skip to content

Commit 5d594a1

Browse files
committed
docs(http-extension): 为 Http.Extension 项目添加双语文档注释
为 HttpClient 扩展方法添加标准的中英双语文档注释: - summary 使用中文描述 - remarks 包含英文翻译 - param/returns/typeparam 使用 "中文 / English" 格式 - exception 使用 "中文描述 / English description" 格式
1 parent d751008 commit 5d594a1

7 files changed

Lines changed: 662 additions & 491 deletions

GameFrameX.Foundation.Http.Extension/HttpClientDeleteExtension.cs

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
namespace GameFrameX.Foundation.Http.Extension;
22

33
/// <summary>
4-
/// HttpClient的DELETE请求扩展方法
4+
/// HttpClient的DELETE请求扩展方法
55
/// </summary>
6+
/// <remarks>
7+
/// Provides extension methods for HttpClient DELETE requests.
8+
/// </remarks>
69
public static class HttpClientDeleteExtension
710
{
811
/// <summary>
9-
/// 发送DELETE请求,并将响应内容读取为字符串
12+
/// 发送DELETE请求,并将响应内容读取为字符串
1013
/// </summary>
11-
/// <param name="httpClient">HttpClient实例</param>
12-
/// <param name="url">请求URL</param>
13-
/// <param name="cancellationToken">取消令牌</param>
14-
/// <returns>响应内容的字符串形式</returns>
15-
/// <exception cref="ArgumentNullException">当httpClient或url为null时抛出</exception>
16-
/// <exception cref="ArgumentException">当url为空字符串或空白字符串时抛出</exception>
17-
/// <exception cref="HttpRequestException">当HTTP响应状态码表示失败时抛出</exception>
14+
/// <remarks>
15+
/// Sends a DELETE request and reads the response content as a string.
16+
/// </remarks>
17+
/// <param name="httpClient">HttpClient实例 / The HttpClient instance</param>
18+
/// <param name="url">请求URL / The request URL</param>
19+
/// <param name="cancellationToken">取消令牌 / The cancellation token</param>
20+
/// <returns>响应内容的字符串形式 / The response content as a string</returns>
21+
/// <exception cref="ArgumentNullException">当 <paramref name="httpClient"/> 或 <paramref name="url"/> 为 null 时抛出 / Thrown when <paramref name="httpClient"/> or <paramref name="url"/> is null</exception>
22+
/// <exception cref="ArgumentException">当 <paramref name="url"/> 为空字符串或空白字符串时抛出 / Thrown when <paramref name="url"/> is empty or whitespace</exception>
23+
/// <exception cref="HttpRequestException">当HTTP响应状态码表示失败时抛出 / Thrown when the HTTP response status code indicates failure</exception>
1824
public static async Task<string> DeleteToStringAsync(this HttpClient httpClient, string url, CancellationToken cancellationToken = default)
1925
{
2026
ArgumentNullException.ThrowIfNull(httpClient, nameof(httpClient));
@@ -25,17 +31,20 @@ public static async Task<string> DeleteToStringAsync(this HttpClient httpClient,
2531
}
2632

2733
/// <summary>
28-
/// 发送DELETE请求,并将响应内容读取为字符串
34+
/// 发送DELETE请求,并将响应内容读取为字符串
2935
/// </summary>
30-
/// <param name="httpClient">HttpClient实例</param>
31-
/// <param name="url">请求URL</param>
32-
/// <param name="headers">请求头字典</param>
33-
/// <param name="timeout">超时时间(秒),默认10秒</param>
34-
/// <param name="cancellationToken">取消令牌</param>
35-
/// <returns>响应内容的字符串形式</returns>
36-
/// <exception cref="ArgumentNullException">当httpClient或url为null时抛出</exception>
37-
/// <exception cref="ArgumentException">当url为空字符串或空白字符串时抛出</exception>
38-
/// <exception cref="HttpRequestException">当HTTP响应状态码表示失败时抛出</exception>
36+
/// <remarks>
37+
/// Sends a DELETE request with custom headers and reads the response content as a string.
38+
/// </remarks>
39+
/// <param name="httpClient">HttpClient实例 / The HttpClient instance</param>
40+
/// <param name="url">请求URL / The request URL</param>
41+
/// <param name="headers">请求头字典 / The request headers dictionary</param>
42+
/// <param name="timeout">超时时间(秒),默认10秒 / Timeout in seconds, default is 10 seconds</param>
43+
/// <param name="cancellationToken">取消令牌 / The cancellation token</param>
44+
/// <returns>响应内容的字符串形式 / The response content as a string</returns>
45+
/// <exception cref="ArgumentNullException">当 <paramref name="httpClient"/> 或 <paramref name="url"/> 为 null 时抛出 / Thrown when <paramref name="httpClient"/> or <paramref name="url"/> is null</exception>
46+
/// <exception cref="ArgumentException">当 <paramref name="url"/> 为空字符串或空白字符串时抛出 / Thrown when <paramref name="url"/> is empty or whitespace</exception>
47+
/// <exception cref="HttpRequestException">当HTTP响应状态码表示失败时抛出 / Thrown when the HTTP response status code indicates failure</exception>
3948
public static async Task<string> DeleteToStringAsync(this HttpClient httpClient, string url, IDictionary<string, string> headers, int timeout = 10, CancellationToken cancellationToken = default)
4049
{
4150
ArgumentNullException.ThrowIfNull(httpClient, nameof(httpClient));
@@ -51,15 +60,18 @@ public static async Task<string> DeleteToStringAsync(this HttpClient httpClient,
5160
}
5261

5362
/// <summary>
54-
/// 发送DELETE请求,并将响应内容读取为字节数组
63+
/// 发送DELETE请求,并将响应内容读取为字节数组
5564
/// </summary>
56-
/// <param name="httpClient">HttpClient实例</param>
57-
/// <param name="url">请求URL</param>
58-
/// <param name="cancellationToken">取消令牌</param>
59-
/// <returns>响应内容的字节数组形式</returns>
60-
/// <exception cref="ArgumentNullException">当httpClient或url为null时抛出</exception>
61-
/// <exception cref="ArgumentException">当url为空字符串或空白字符串时抛出</exception>
62-
/// <exception cref="HttpRequestException">当HTTP响应状态码表示失败时抛出</exception>
65+
/// <remarks>
66+
/// Sends a DELETE request and reads the response content as a byte array.
67+
/// </remarks>
68+
/// <param name="httpClient">HttpClient实例 / The HttpClient instance</param>
69+
/// <param name="url">请求URL / The request URL</param>
70+
/// <param name="cancellationToken">取消令牌 / The cancellation token</param>
71+
/// <returns>响应内容的字节数组形式 / The response content as a byte array</returns>
72+
/// <exception cref="ArgumentNullException">当 <paramref name="httpClient"/> 或 <paramref name="url"/> 为 null 时抛出 / Thrown when <paramref name="httpClient"/> or <paramref name="url"/> is null</exception>
73+
/// <exception cref="ArgumentException">当 <paramref name="url"/> 为空字符串或空白字符串时抛出 / Thrown when <paramref name="url"/> is empty or whitespace</exception>
74+
/// <exception cref="HttpRequestException">当HTTP响应状态码表示失败时抛出 / Thrown when the HTTP response status code indicates failure</exception>
6375
public static async Task<byte[]> DeleteToByteArrayAsync(this HttpClient httpClient, string url, CancellationToken cancellationToken = default)
6476
{
6577
ArgumentNullException.ThrowIfNull(httpClient, nameof(httpClient));
@@ -70,17 +82,20 @@ public static async Task<byte[]> DeleteToByteArrayAsync(this HttpClient httpClie
7082
}
7183

7284
/// <summary>
73-
/// 发送DELETE请求,并将响应内容读取为字节数组
85+
/// 发送DELETE请求,并将响应内容读取为字节数组
7486
/// </summary>
75-
/// <param name="httpClient">HttpClient实例</param>
76-
/// <param name="url">请求URL</param>
77-
/// <param name="headers">请求头字典</param>
78-
/// <param name="timeout">超时时间(秒),默认10秒</param>
79-
/// <param name="cancellationToken">取消令牌</param>
80-
/// <returns>响应内容的字节数组形式</returns>
81-
/// <exception cref="ArgumentNullException">当httpClient或url为null时抛出</exception>
82-
/// <exception cref="ArgumentException">当url为空字符串或空白字符串时抛出</exception>
83-
/// <exception cref="HttpRequestException">当HTTP响应状态码表示失败时抛出</exception>
87+
/// <remarks>
88+
/// Sends a DELETE request with custom headers and reads the response content as a byte array.
89+
/// </remarks>
90+
/// <param name="httpClient">HttpClient实例 / The HttpClient instance</param>
91+
/// <param name="url">请求URL / The request URL</param>
92+
/// <param name="headers">请求头字典 / The request headers dictionary</param>
93+
/// <param name="timeout">超时时间(秒),默认10秒 / Timeout in seconds, default is 10 seconds</param>
94+
/// <param name="cancellationToken">取消令牌 / The cancellation token</param>
95+
/// <returns>响应内容的字节数组形式 / The response content as a byte array</returns>
96+
/// <exception cref="ArgumentNullException">当 <paramref name="httpClient"/> 或 <paramref name="url"/> 为 null 时抛出 / Thrown when <paramref name="httpClient"/> or <paramref name="url"/> is null</exception>
97+
/// <exception cref="ArgumentException">当 <paramref name="url"/> 为空字符串或空白字符串时抛出 / Thrown when <paramref name="url"/> is empty or whitespace</exception>
98+
/// <exception cref="HttpRequestException">当HTTP响应状态码表示失败时抛出 / Thrown when the HTTP response status code indicates failure</exception>
8499
public static async Task<byte[]> DeleteToByteArrayAsync(this HttpClient httpClient, string url, IDictionary<string, string> headers, int timeout = 10, CancellationToken cancellationToken = default)
85100
{
86101
ArgumentNullException.ThrowIfNull(httpClient, nameof(httpClient));
@@ -96,11 +111,14 @@ public static async Task<byte[]> DeleteToByteArrayAsync(this HttpClient httpClie
96111
}
97112

98113
/// <summary>
99-
/// 创建DELETE请求消息
114+
/// 创建DELETE请求消息
100115
/// </summary>
101-
/// <param name="url">请求URL</param>
102-
/// <param name="headers">请求头字典</param>
103-
/// <returns>HttpRequestMessage实例</returns>
116+
/// <remarks>
117+
/// Creates a DELETE request message with custom headers.
118+
/// </remarks>
119+
/// <param name="url">请求URL / The request URL</param>
120+
/// <param name="headers">请求头字典 / The request headers dictionary</param>
121+
/// <returns>HttpRequestMessage实例 / The HttpRequestMessage instance</returns>
104122
private static HttpRequestMessage CreateDeleteRequest(string url, IDictionary<string, string> headers)
105123
{
106124
var request = new HttpRequestMessage(HttpMethod.Delete, url);

0 commit comments

Comments
 (0)