using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using System.IO; using zero.Backoffice.Endpoints.Account; using zero.Backoffice.Endpoints.Pages; using zero.Backoffice.Services; namespace zero.Backoffice; public class ZeroBackofficePlugin : ZeroPlugin { internal Action PostConfigureServices = null; public ZeroBackofficePlugin() { Options.Name = "zero.Backoffice"; Options.LocalizationPaths.Add("~/Resources/Localization/zero.{lang}.json"); } public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { services.AddOptions().Bind(configuration.GetSection("Zero:Backoffice")).Configure(ConfigureOptions); services.TryAddEnumerable(ServiceDescriptor.Transient, ZeroBackofficeMvcOptions>()); services.AddHostedService(); services.AddTransient(); services.AddSingleton(); services.AddScoped(); services.AddSingleton(); services.AddSingleton(); services.AddScoped(); services.AddSingleton(svc => { IOptions options = svc.GetRequiredService>(); IWebHostEnvironment env = svc.GetRequiredService(); return new(Path.Combine(env.WebRootPath, options.Value.AssetPath)); }); services.AddZeroBackofficeUIComposition(); //services.AddTransient(); //services.AddTransient(); //services.AddScoped(); PostConfigureServices?.Invoke(services, configuration); } protected void ConfigureOptions(BackofficeOptions options, IWebHostEnvironment env) { options.ExcludedPaths.Add("resources"); options.AssetPath = "zero/resources"; options.DevServer.WorkingDirectory = Path.Combine(env.ContentRootPath, "..", "Zero.Web.UI", "App"); options.IconSets.Add(new BackofficeIconSet() { Alias = "feather", Name = "Feather", SpritePath = "icons/feather.svg", Prefix = "fth" }); options.SupportedLanguages = new string[2] { "en-US", "de-DE" }; options.DefaultLanguage = options.SupportedLanguages[0]; } }