Skip to content

Commit

Permalink
Use shorthand syntax for empty arrays
Browse files Browse the repository at this point in the history
Updated `CustomMenuSettings.cs` and `HtmlHelper.cs` to use the shorthand `[]` for initializing empty arrays instead of `Array.Empty<T>()` and `Enumerable.Empty<T>()`. This change enhances code readability while maintaining the same functionality.
  • Loading branch information
EdiWang committed Oct 30, 2024
1 parent 5fab886 commit 9efa082
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Moonglade.Configuration/CustomMenuSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CustomMenuSettings : IBlogSettings
public bool IsEnabled { get; set; }

[MaxLength(5)]
public Menu[] Menus { get; set; } = Array.Empty<Menu>();
public Menu[] Menus { get; set; } = [];

[JsonIgnore]
public static CustomMenuSettings DefaultValue =>
Expand Down
12 changes: 6 additions & 6 deletions src/Moonglade.Web/PagedList/HtmlHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private TagBuilder First(IPagedList list, Func<int, string> generatePageUrl, Pag

AppendHtml(first, string.Format(options.LinkToFirstPageFormat, targetPageNumber));

foreach (var c in options.PageClasses ?? Enumerable.Empty<string>())
foreach (var c in options.PageClasses ?? [])
{
first.AddCssClass(c);
}
Expand All @@ -74,7 +74,7 @@ private TagBuilder Previous(IPagedList list, Func<int, string> generatePageUrl,

previous.Attributes.Add("rel", "prev");

foreach (var c in options.PageClasses ?? Enumerable.Empty<string>())
foreach (var c in options.PageClasses ?? [])
{
previous.AddCssClass(c);
}
Expand All @@ -100,7 +100,7 @@ private TagBuilder Page(int i, IPagedList list, Func<int, string> generatePageUr

SetInnerText(page, format(targetPageNumber));

foreach (var c in options.PageClasses ?? Enumerable.Empty<string>())
foreach (var c in options.PageClasses ?? [])
{
page.AddCssClass(c);
}
Expand All @@ -124,7 +124,7 @@ private TagBuilder Next(IPagedList list, Func<int, string> generatePageUrl, Page

next.Attributes.Add("rel", "next");

foreach (var c in options.PageClasses ?? Enumerable.Empty<string>())
foreach (var c in options.PageClasses ?? [])
{
next.AddCssClass(c);
}
Expand All @@ -146,7 +146,7 @@ private TagBuilder Last(IPagedList list, Func<int, string> generatePageUrl, Page

AppendHtml(last, string.Format(options.LinkToLastPageFormat, targetPageNumber));

foreach (var c in options.PageClasses ?? Enumerable.Empty<string>())
foreach (var c in options.PageClasses ?? [])
{
last.AddCssClass(c);
}
Expand Down Expand Up @@ -261,7 +261,7 @@ public string PagedListPager(IPagedList pagedList, Func<int, string> generatePag

AppendHtml(ul, listItemLinksString);

foreach (var c in options.UlElementClasses ?? Enumerable.Empty<string>())
foreach (var c in options.UlElementClasses ?? [])
{
ul.AddCssClass(c);
}
Expand Down

0 comments on commit 9efa082

Please sign in to comment.