重构代码:更改Count() > 0 为 Any() 优化性能

This commit is contained in:
Argo-Surface 2019-01-12 15:54:05 +08:00
parent 441e41dc85
commit 8f32a12e4e
4 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,7 @@ namespace Bootstrap.Admin
{
if (operation.Parameters == null) operation.Parameters = new List<IParameter>();
if (context.MethodInfo.GetCustomAttributes(typeof(AllowAnonymousAttribute), true).Count() == 0)
if (context.MethodInfo.GetCustomAttributes(typeof(AllowAnonymousAttribute), true).Length == 0)
{
operation.Parameters.Add(new NonBodyParameter()
{

View File

@ -1,7 +1,7 @@
@model Bootstrap.Security.BootstrapMenu
<li class="nav-item @Model.Active">
<a href="@Url.Content(Model.Url)" class="nav-link @Model.Active" target="@Model.Target"><i class="@Model.Icon"></i>@Model.Name</a>
@if (Model.Menus.Count() > 0)
@if (Model.Menus.Any())
{
@await Html.PartialAsync("SubNavigation", Model.Menus)
}

View File

@ -45,7 +45,7 @@
<div class="navbar-nav">
@foreach (var menu in Model.Navigations)
{
@if (menu.Menus.Count() > 0)
@if (menu.Menus.Any())
{
<div class="nav-item dropdown @menu.Active">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" href="#">@menu.Name</a>

View File

@ -1,7 +1,7 @@
@model Bootstrap.Security.BootstrapMenu
<li class="nav-item @Model.Active">
<a href="@Url.Content(Model.Url)" class="nav-link @Model.Active" target="@Model.Target"><i class="@Model.Icon"></i>@Model.Name</a>
@if (Model.Menus.Count() > 0)
@if (Model.Menus.Any())
{
@await Html.PartialAsync("SubNavigation", Model.Menus)
}