You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
using Microsoft.Extensions.Options;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.DependencyInjection;
|
|
|
|
namespace Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.PageToolbars;
|
|
|
|
public class PageToolbarManager : IPageToolbarManager, ITransientDependency
|
|
{
|
|
protected IHybridServiceScopeFactory ServiceScopeFactory { get; }
|
|
|
|
public PageToolbarManager(
|
|
IHybridServiceScopeFactory serviceScopeFactory)
|
|
{
|
|
ServiceScopeFactory = serviceScopeFactory;
|
|
}
|
|
|
|
public virtual async Task<PageToolbarItem[]> GetItemsAsync(PageToolbar toolbar)
|
|
{
|
|
if (toolbar == null || !toolbar.Contributors.Any())
|
|
{
|
|
return Array.Empty<PageToolbarItem>();
|
|
}
|
|
|
|
using (var scope = ServiceScopeFactory.CreateScope())
|
|
{
|
|
var context = new PageToolbarContributionContext(scope.ServiceProvider);
|
|
|
|
foreach (var contributor in toolbar.Contributors)
|
|
{
|
|
await contributor.ContributeAsync(context);
|
|
}
|
|
|
|
return context.Items.OrderBy(i => i.Order).ToArray();
|
|
}
|
|
}
|
|
}
|
|
|