Skip to content

Commit dceafa2

Browse files
authored
Merge pull request #2 from willysoft/docs/translate-xml-comments
docs: Translate XML comments from Chinese to English
2 parents d2f1e10 + ad80af4 commit dceafa2

17 files changed

+341
-341
lines changed

src/AutoQuery.AspNetCore/AutoQueryServiceExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
namespace Microsoft.AspNetCore.Builder;
99

1010
/// <summary>
11-
/// 提供查詢服務相關的擴展方法。
11+
/// Provides extension methods related to query services.
1212
/// </summary>
1313
public static class AutoQueryServiceExtensions
1414
{
1515
/// <summary>
16-
/// 向服務集合中添加查詢建構器服務。
16+
/// Adds query builder services to the service collection.
1717
/// </summary>
18-
/// <param name="services">服務集合。</param>
19-
/// <param name="assembly">要應用配置的程序集。</param>
20-
/// <returns>更新後的服務集合。</returns>
18+
/// <param name="services">The service collection.</param>
19+
/// <param name="assembly">The assembly to apply configurations from.</param>
20+
/// <returns>The updated service collection.</returns>
2121
public static IServiceCollection AddAutoQuery(this IServiceCollection services, Assembly assembly)
2222
{
2323
ArgumentNullException.ThrowIfNull(services);

src/AutoQuery.AspNetCore/EnableFieldProjectionAttribute.cs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace AutoQuery.AspNetCore;
1414

1515
/// <summary>
16-
/// 字段投影屬性,用於在返回結果中僅包含指定的字段。
16+
/// Field projection attribute used to include only specified fields in the returned result.
1717
/// </summary>
1818
public class EnableFieldProjectionAttribute : ActionFilterAttribute
1919
{
@@ -24,18 +24,18 @@ public class EnableFieldProjectionAttribute : ActionFilterAttribute
2424
private IQueryOptions? _queryOptions;
2525

2626
/// <summary>
27-
/// 在操作執行之前調用,從操作參數中提取 QueryOptions
27+
/// Called before the action is executed to extract QueryOptions from the action parameters.
2828
/// </summary>
29-
/// <param name="context">操作執行上下文。</param>
29+
/// <param name="context">The action execution context.</param>
3030
public override void OnActionExecuting(ActionExecutingContext context)
3131
{
3232
_queryOptions = ExtractQueryOptions(context);
3333
}
3434

3535
/// <summary>
36-
/// 在操作執行之後調用,根據指定的字段過濾返回結果。
36+
/// Called after the action is executed to filter the returned result based on the specified fields.
3737
/// </summary>
38-
/// <param name="context">操作執行上下文。</param>
38+
/// <param name="context">The action execution context.</param>
3939
public override void OnActionExecuted(ActionExecutedContext context)
4040
{
4141
if (_queryOptions == null || string.IsNullOrEmpty(_queryOptions.Fields))
@@ -53,12 +53,12 @@ public override void OnActionExecuted(ActionExecutedContext context)
5353
}
5454

5555
/// <summary>
56-
/// 過濾結果,僅包含選擇的字段。
56+
/// Filters the result to include only the selected fields.
5757
/// </summary>
58-
/// <param name="value">要過濾的對象。</param>
59-
/// <param name="selectedFields">選擇的字段集合。</param>
60-
/// <param name="serializerOptions">JSON 序列化選項。</param>
61-
/// <returns>過濾後的對象。</returns>
58+
/// <param name="value">The object to filter.</param>
59+
/// <param name="selectedFields">The set of selected fields.</param>
60+
/// <param name="serializerOptions">JSON serialization options.</param>
61+
/// <returns>The filtered object.</returns>
6262
private static object FilterResult(object value, HashSet<string> selectedFields, JsonSerializerOptions serializerOptions)
6363
{
6464
if (value is IEnumerable<object> enumerable)
@@ -76,12 +76,12 @@ private static object FilterResult(object value, HashSet<string> selectedFields,
7676
}
7777

7878
/// <summary>
79-
/// 過濾集合類型的結果。
79+
/// Filters a collection-type result.
8080
/// </summary>
81-
/// <param name="enumerable">要過濾的集合。</param>
82-
/// <param name="selectedFields">選擇的字段集合。</param>
83-
/// <param name="serializerOptions">JSON 序列化選項。</param>
84-
/// <returns>過濾後的集合。</returns>
81+
/// <param name="enumerable">The collection to filter.</param>
82+
/// <param name="selectedFields">The set of selected fields.</param>
83+
/// <param name="serializerOptions">JSON serialization options.</param>
84+
/// <returns>The filtered collection.</returns>
8585
private static List<Dictionary<string, object?>> FilterEnumerable(IEnumerable<object> enumerable, HashSet<string> selectedFields, JsonSerializerOptions serializerOptions)
8686
{
8787
var result = new List<Dictionary<string, object?>>();
@@ -94,13 +94,13 @@ private static object FilterResult(object value, HashSet<string> selectedFields,
9494
}
9595

9696
/// <summary>
97-
/// 過濾單個物件的結果。
97+
/// Filters the result of a single object.
9898
/// </summary>
99-
/// <param name="value">要過濾的物件。</param>
100-
/// <param name="selectedFields">選擇的字段集合。</param>
101-
/// <param name="serializerOptions">JSON 序列化選項。</param>
102-
/// <param name="firstLevelOnly">是否僅過濾第一層屬性。</param>
103-
/// <returns>過濾後的字典。</returns>
99+
/// <param name="value">The object to filter.</param>
100+
/// <param name="selectedFields">The set of selected fields.</param>
101+
/// <param name="serializerOptions">JSON serialization options.</param>
102+
/// <param name="firstLevelOnly">Whether to filter only the first-level properties.</param>
103+
/// <returns>The filtered dictionary.</returns>
104104
private static Dictionary<string, object?> FilterObject(object value, HashSet<string> selectedFields, JsonSerializerOptions serializerOptions, bool firstLevelOnly = false)
105105
{
106106
var result = new Dictionary<string, object?>();
@@ -138,20 +138,20 @@ private static object FilterResult(object value, HashSet<string> selectedFields,
138138
}
139139

140140
/// <summary>
141-
/// 從操作上下文中提取 QueryOptions
141+
/// Extracts QueryOptions from the action context.
142142
/// </summary>
143-
/// <param name="context">操作執行上下文。</param>
144-
/// <returns>提取的 QueryOptions</returns>
143+
/// <param name="context">The action execution context.</param>
144+
/// <returns>The extracted QueryOptions.</returns>
145145
private static IQueryOptions? ExtractQueryOptions(ActionExecutingContext context)
146146
{
147147
return context.ActionArguments.Values.OfType<IQueryOptions>().FirstOrDefault();
148148
}
149149

150150
/// <summary>
151-
/// 解析選擇的字段。
151+
/// Parses the selected fields.
152152
/// </summary>
153-
/// <param name="fields">逗號分隔的字段名稱。</param>
154-
/// <returns>選擇的字段集合。</returns>
153+
/// <param name="fields">Comma-separated field names.</param>
154+
/// <returns>The set of selected fields.</returns>
155155
private static HashSet<string> ParseSelectedFields(string fields)
156156
{
157157
return fields.Split(',')
@@ -160,21 +160,21 @@ private static HashSet<string> ParseSelectedFields(string fields)
160160
}
161161

162162
/// <summary>
163-
/// 獲取 JSON 序列化選項。
163+
/// Gets the JSON serialization options.
164164
/// </summary>
165-
/// <param name="context">操作執行上下文。</param>
166-
/// <returns>JSON 序列化選項。</returns>
165+
/// <param name="context">The action execution context.</param>
166+
/// <returns>The JSON serialization options.</returns>
167167
private static JsonSerializerOptions GetSerializerOptions(ActionExecutedContext context)
168168
{
169169
return context.HttpContext.RequestServices.GetRequiredService<IOptions<JsonOptions>>().Value.JsonSerializerOptions;
170170
}
171171

172172
/// <summary>
173-
/// 使用表達樹取得屬性的值。
173+
/// Gets the value of a property using expression trees.
174174
/// </summary>
175-
/// <param name="property">屬性信息。</param>
176-
/// <param name="instance">對象實例。</param>
177-
/// <returns>屬性的值。</returns>
175+
/// <param name="property">The property information.</param>
176+
/// <param name="instance">The object instance.</param>
177+
/// <returns>The value of the property.</returns>
178178
private static object? GetPropertyValue(PropertyInfo property, object instance)
179179
{
180180
if (!_propertyAccessorsCache.TryGetValue(property, out var accessor))
@@ -191,11 +191,11 @@ private static JsonSerializerOptions GetSerializerOptions(ActionExecutedContext
191191
}
192192

193193
/// <summary>
194-
/// 獲取屬性的 JSON 屬性名稱。
194+
/// Gets the JSON property name of a property.
195195
/// </summary>
196-
/// <param name="propInfo">屬性信息。</param>
197-
/// <param name="serializerOptions">JSON 序列化選項。</param>
198-
/// <returns>屬性的 JSON 名稱。</returns>
196+
/// <param name="propInfo">The property information.</param>
197+
/// <param name="serializerOptions">JSON serialization options.</param>
198+
/// <returns>The JSON name of the property.</returns>
199199
private static string GetJsonPropertyName(PropertyInfo propInfo, JsonSerializerOptions serializerOptions)
200200
{
201201
var jsonPropertyNameAttr = _jsonPropertyNameCache[propInfo];
@@ -205,9 +205,9 @@ private static string GetJsonPropertyName(PropertyInfo propInfo, JsonSerializerO
205205
}
206206

207207
/// <summary>
208-
/// 緩存類型的屬性信息。
208+
/// Caches the property information of a type.
209209
/// </summary>
210-
/// <param name="type">要緩存的類型。</param>
210+
/// <param name="type">The type to cache.</param>
211211
private static void CacheProperties(Type type)
212212
{
213213
if (!_propertyInfoCache.ContainsKey(type))
@@ -224,10 +224,10 @@ private static void CacheProperties(Type type)
224224
}
225225

226226
/// <summary>
227-
/// 確定狀態碼是否表示成功。
227+
/// Determines whether the status code indicates success.
228228
/// </summary>
229-
/// <param name="statusCode">HTTP 狀態碼。</param>
230-
/// <returns>如果狀態碼表示成功,則為 true;否則為 false</returns>
229+
/// <param name="statusCode">The HTTP status code.</param>
230+
/// <returns>True if the status code indicates success; otherwise, false.</returns>
231231
private static bool IsSuccessStatusCode(int statusCode)
232232
{
233233
return statusCode >= 200 && statusCode < 300;

src/AutoQuery/Abstractions/IFilterExpressionBuilder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
namespace AutoQuery.Abstractions;
44

55
/// <summary>
6-
/// 定義篩選查詢屬性建構器的介面。
6+
/// Defines the interface for a filter query property builder.
77
/// </summary>
8-
/// <typeparam name="TData">數據的類型。</typeparam>
9-
/// <typeparam name="TQueryProperty">查詢屬性的類型。</typeparam>
8+
/// <typeparam name="TData">The type of the data.</typeparam>
9+
/// <typeparam name="TQueryProperty">The type of the query property.</typeparam>
1010
public interface IFilterExpressionBuilder<TData, TQueryProperty>
1111
{
1212
/// <summary>
13-
/// 構建篩選表達式。
13+
/// Builds the filter expression.
1414
/// </summary>
15-
/// <param name="filterValue">篩選屬性的值。</param>
16-
/// <returns>篩選表達式。</returns>
15+
/// <param name="filterValue">The value of the filter property.</param>
16+
/// <returns>The filter expression.</returns>
1717
Expression<Func<TData, bool>> BuildFilterExpression(TQueryProperty filterValue);
1818
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
namespace AutoQuery.Abstractions;
22

33
/// <summary>
4-
/// 定義篩選查詢配置的介面。
4+
/// Defines the interface for filter query configuration.
55
/// </summary>
6-
/// <typeparam name="TQueryOptions">查詢選項的類型。</typeparam>
7-
/// <typeparam name="TData">數據的類型。</typeparam>
6+
/// <typeparam name="TQueryOptions">The type of the query options.</typeparam>
7+
/// <typeparam name="TData">The type of the data.</typeparam>
88
public interface IFilterQueryConfiguration<TQueryOptions, TData>
99
{
1010
/// <summary>
11-
/// 配置篩選查詢建構器。
11+
/// Configures the filter query builder.
1212
/// </summary>
13-
/// <param name="builder">篩選查詢建構器。</param>
13+
/// <param name="builder">The filter query builder.</param>
1414
void Configure(FilterQueryBuilder<TQueryOptions, TData> builder);
1515
}

src/AutoQuery/Abstractions/IQueryOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
namespace AutoQuery.Abstractions;
22

33
/// <summary>
4-
/// 查詢參數
4+
/// Query parameters.
55
/// </summary>
66
public interface IQueryOptions
77
{
88
/// <summary>
9-
/// 選擇的欄位
9+
/// Selected fields.
1010
/// </summary>
1111
string? Fields { get; set; }
1212

1313
/// <summary>
14-
/// 排序欄位
14+
/// Sorting fields.
1515
/// </summary>
1616
string? Sort { get; set; }
1717
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
namespace AutoQuery.Abstractions;
22

33
/// <summary>
4-
/// 查詢已分頁參數
4+
/// Query parameters for paginated results.
55
/// </summary>
66
public interface IQueryPagedOptions : IQueryOptions
77
{
88
/// <summary>
9-
/// 當前頁數
9+
/// Current page number.
1010
/// </summary>
1111
int? Page { get; set; }
1212

1313
/// <summary>
14-
/// 每頁資料數量
14+
/// Number of items per page.
1515
/// </summary>
1616
int? PageSize { get; set; }
1717
}

src/AutoQuery/Abstractions/IQueryProcessor.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
namespace AutoQuery.Abstractions;
44

55
/// <summary>
6-
/// 定義查詢建構器服務的介面。
6+
/// Defines the interface for query builder services.
77
/// </summary>
88
public interface IQueryProcessor
99
{
1010
/// <summary>
11-
/// 構建篩選表達式。
11+
/// Builds the filter expression.
1212
/// </summary>
13-
/// <typeparam name="TData">數據的類型。</typeparam>
14-
/// <typeparam name="TQueryOptions">查詢選項的類型。</typeparam>
15-
/// <param name="queryOptions">查詢選項。</param>
16-
/// <returns>篩選表達式,如果沒有篩選條件則為 null</returns>
13+
/// <typeparam name="TData">The type of the data.</typeparam>
14+
/// <typeparam name="TQueryOptions">The type of the query options.</typeparam>
15+
/// <param name="queryOptions">The query options.</param>
16+
/// <returns>The filter expression, or null if no filter conditions exist.</returns>
1717
Expression<Func<TData, bool>>? BuildFilterExpression<TData, TQueryOptions>(TQueryOptions queryOptions)
1818
where TQueryOptions : IQueryOptions;
1919

2020
/// <summary>
21-
/// 構建選擇器表達式。
21+
/// Builds the selector expression.
2222
/// </summary>
23-
/// <typeparam name="TData">數據的類型。</typeparam>
24-
/// <typeparam name="TQueryOptions">查詢選項的類型。</typeparam>
25-
/// <param name="queryOptions">查詢選項。</param>
26-
/// <returns>選擇器表達式,如果沒有選擇條件則為 null</returns>
23+
/// <typeparam name="TData">The type of the data.</typeparam>
24+
/// <typeparam name="TQueryOptions">The type of the query options.</typeparam>
25+
/// <param name="queryOptions">The query options.</param>
26+
/// <returns>The selector expression, or null if no selection conditions exist.</returns>
2727
Expression<Func<TData, TData>>? BuildSelectorExpression<TData, TQueryOptions>(TQueryOptions queryOptions)
2828
where TQueryOptions : IQueryOptions;
2929
}

src/AutoQuery/ComplexFilterQueryPropertyBuilder.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55
namespace AutoQuery;
66

77
/// <summary>
8-
/// 用於構建篩選查詢屬性的建構器類別。
8+
/// A builder class for constructing filter query properties.
99
/// </summary>
10-
/// <typeparam name="TData">數據的類型。</typeparam>
11-
/// <typeparam name="TQueryProperty">查詢屬性的類型。</typeparam>
12-
/// <typeparam name="TDataProperty">數據屬性的類型。</typeparam>
10+
/// <typeparam name="TData">The type of the data.</typeparam>
11+
/// <typeparam name="TQueryProperty">The type of the query property.</typeparam>
12+
/// <typeparam name="TDataProperty">The type of the data property.</typeparam>
1313
public class ComplexFilterQueryPropertyBuilder<TData, TQueryProperty, TDataProperty> : IFilterExpressionBuilder<TData, TQueryProperty>
1414
{
1515
private Expression<Func<TData, TDataProperty>> _filterKeySelector;
1616
private List<(Expression<Func<TQueryProperty, TDataProperty, bool>> Expression, LogicalOperator Logical)> _filterExpressions = new();
1717

1818
/// <summary>
19-
/// 初始化 <see cref="ComplexFilterQueryPropertyBuilder{TData, TQueryProperty, TDataProperty}"/> 類別的新實例。
19+
/// Initializes a new instance of the <see cref="ComplexFilterQueryPropertyBuilder{TData, TQueryProperty, TDataProperty}"/> class.
2020
/// </summary>
21-
/// <param name="filterKeySelector">數據中的篩選鍵選擇器。</param>
21+
/// <param name="filterKeySelector">The filter key selector in the data.</param>
2222
public ComplexFilterQueryPropertyBuilder(Expression<Func<TData, TDataProperty>> filterKeySelector)
2323
{
2424
_filterKeySelector = filterKeySelector;
2525
}
2626

2727
/// <summary>
28-
/// 添加篩選表達式。
28+
/// Adds a filter expression.
2929
/// </summary>
30-
/// <param name="filterExpression">篩選表達式。</param>
31-
/// <param name="logicalOperator">邏輯運算符。</param>
30+
/// <param name="filterExpression">The filter expression.</param>
31+
/// <param name="logicalOperator">The logical operator.</param>
3232
public void AddFilterExpression(Expression<Func<TQueryProperty, TDataProperty, bool>> filterExpression, LogicalOperator logicalOperator)
3333
{
3434
_filterExpressions.Add((filterExpression, logicalOperator));
@@ -56,4 +56,4 @@ public Expression<Func<TData, bool>> BuildFilterExpression(TQueryProperty filter
5656

5757
return Expression.Lambda<Func<TData, bool>>(finalExpression ?? Expression.Constant(true), parameter);
5858
}
59-
}
59+
}

0 commit comments

Comments
 (0)