Skip to content

Commit c8746fa

Browse files
committed
refactor: 重构代码消除警告信息
1 parent 7921a8a commit c8746fa

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private async Task OnClickItem(TValue val)
135135

136136
private string? GetDisplayText(TValue item) => OnGetDisplayText?.Invoke(item) ?? item?.ToString();
137137

138-
private List<TValue> Rows => _filterItems ?? Items.ToList();
138+
private List<TValue> Rows => _filterItems ?? [.. Items];
139139

140140
/// <summary>
141141
/// TriggerFilter 方法
@@ -147,24 +147,24 @@ public override async Task TriggerFilter(string val)
147147
if (OnCustomFilter != null)
148148
{
149149
var items = await OnCustomFilter(val);
150-
_filterItems = items.ToList();
150+
_filterItems = [.. items];
151151
}
152152
else if (string.IsNullOrEmpty(val))
153153
{
154-
_filterItems = Items.ToList();
154+
_filterItems = [.. Items];
155155
}
156156
else
157157
{
158158
var comparision = IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
159159
var items = IsLikeMatch
160160
? Items.Where(i => OnGetDisplayText?.Invoke(i)?.Contains(val, comparision) ?? false)
161161
: Items.Where(i => OnGetDisplayText?.Invoke(i)?.StartsWith(val, comparision) ?? false);
162-
_filterItems = items.ToList();
162+
_filterItems = [.. items];
163163
}
164164

165165
if (DisplayCount != null)
166166
{
167-
_filterItems = _filterItems.Take(DisplayCount.Value).ToList();
167+
_filterItems = [.. _filterItems.Take(DisplayCount.Value)];
168168
}
169169
StateHasChanged();
170170
}

0 commit comments

Comments
 (0)