/
aprogrammer
/
ACme.BookStore
Обзор
Документация
Войти
/
aprogrammer
/
ACme.BookStore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/ACme.BookStore.Blazor/BookStoreBlazorModule.cs
103 строки
4 KB
nicolaujoao1
Add project files.
29 сен 2022, 16:22
29 сен 2022, 16:22
e371a9d
Код
Авторство
О чём код?
using System; using System.Net.Http; using Blazorise.Bootstrap5; using Blazorise.Icons.FontAwesome; using IdentityModel; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using ACme.BookStore.Blazor.Menus; using Volo.Abp.AspNetCore.Components.Web.BasicTheme.Themes.Basic; using Volo.Abp.AspNetCore.Components.Web.Theming.Routing; using Volo.Abp.Autofac.WebAssembly; using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; using Volo.Abp.UI.Navigation; using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme; using Volo.Abp.Identity.Blazor.WebAssembly; using Volo.Abp.SettingManagement.Blazor.WebAssembly; using Volo.Abp.TenantManagement.Blazor.WebAssembly; namespace ACme.BookStore.Blazor; [DependsOn( typeof(AbpAutofacWebAssemblyModule), typeof(BookStoreHttpApiClientModule), typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule), typeof(AbpIdentityBlazorWebAssemblyModule), typeof(AbpTenantManagementBlazorWebAssemblyModule), typeof(AbpSettingManagementBlazorWebAssemblyModule) )] public class BookStoreBlazorModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>(); var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>(); ConfigureAuthentication(builder); ConfigureHttpClient(context, environment); ConfigureBlazorise(context); ConfigureRouter(context); ConfigureUI(builder); ConfigureMenu(context); ConfigureAutoMapper(context); } private void ConfigureRouter(ServiceConfigurationContext context) { Configure<AbpRouterOptions>(options => { options.AppAssembly = typeof(BookStoreBlazorModule).Assembly; }); } private void ConfigureMenu(ServiceConfigurationContext context) { Configure<AbpNavigationOptions>(options => { options.MenuContributors.Add(new BookStoreMenuContributor(context.Services.GetConfiguration())); }); } private void ConfigureBlazorise(ServiceConfigurationContext context) { context.Services .AddBootstrap5Providers() .AddFontAwesomeIcons(); } private static void ConfigureAuthentication(WebAssemblyHostBuilder builder) { builder.Services.AddOidcAuthentication(options => { builder.Configuration.Bind("AuthServer", options.ProviderOptions); options.UserOptions.RoleClaim = JwtClaimTypes.Role; options.ProviderOptions.DefaultScopes.Add("BookStore"); options.ProviderOptions.DefaultScopes.Add("role"); options.ProviderOptions.DefaultScopes.Add("email"); options.ProviderOptions.DefaultScopes.Add("phone"); }); } private static void ConfigureUI(WebAssemblyHostBuilder builder) { builder.RootComponents.Add<App>("#ApplicationContainer"); } private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment) { context.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(environment.BaseAddress) }); } private void ConfigureAutoMapper(ServiceConfigurationContext context) { Configure<AbpAutoMapperOptions>(options => { options.AddMaps<BookStoreBlazorModule>(); }); } }