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 System;
|
|
using System.Threading.Tasks;
|
|
using Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Toolbars;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Options;
|
|
using Volo.Abp.DependencyInjection;
|
|
|
|
namespace Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Toolbars;
|
|
|
|
public class ToolbarManager : IToolbarManager, ITransientDependency
|
|
{
|
|
protected AbpToolbarOptions Options { get; }
|
|
protected IServiceProvider ServiceProvider { get; }
|
|
|
|
public ToolbarManager(
|
|
IOptions<AbpToolbarOptions> options,
|
|
IServiceProvider serviceProvider)
|
|
{
|
|
ServiceProvider = serviceProvider;
|
|
Options = options.Value;
|
|
}
|
|
|
|
public async Task<Toolbar> GetAsync(string name)
|
|
{
|
|
var toolbar = new Toolbar(name);
|
|
|
|
using (var scope = ServiceProvider.CreateScope())
|
|
{
|
|
var context = new ToolbarConfigurationContext(toolbar, scope.ServiceProvider);
|
|
|
|
foreach (var contributor in Options.Contributors)
|
|
{
|
|
await contributor.ConfigureToolbarAsync(context);
|
|
}
|
|
}
|
|
|
|
return toolbar;
|
|
}
|
|
}
|
|
|