// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSingleton(this.Configuration); services.AddAllors(); services.AddSingleton <IPolicyService, PolicyService>(); services.AddSingleton <IExtentService, ExtentService>(); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDefaultIdentity <IdentityUser>() .AddAllorsStores(); services.AddSingleton <Allors.Workspace.Local.LocalDatabase>(); services.AddSingleton <Allors.Workspace.IDatabase>(provider => provider.GetRequiredService <Allors.Workspace.Local.LocalDatabase>()); services.AddSingleton <Allors.Workspace.Workspace>((serviceProvider) => { var objectFactory = new Allors.Workspace.ObjectFactory(Allors.Workspace.Meta.MetaPopulation.Instance, typeof(Allors.Workspace.Domain.User)); var workspace = new Allors.Workspace.Workspace(objectFactory); return(workspace); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddSingleton(this.Configuration); services.AddAllors(); services.AddSingleton <IPolicyService, PolicyService>(); services.AddSingleton <IExtentService, ExtentService>(); services.AddDefaultIdentity <IdentityUser>() .AddAllorsStores(); services.AddRazorPages(); services.AddServerSideBlazor().AddCircuitOptions(circuitOptions => { if (this.Environment.IsDevelopment()) { circuitOptions.DetailedErrors = true; } }); services.AddScoped <AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider <IdentityUser> >(); services.AddSingleton <Allors.Workspace.Local.LocalDatabase>(); services.AddSingleton <Allors.Workspace.IDatabase>(provider => provider.GetRequiredService <Allors.Workspace.Local.LocalDatabase>()); services.AddSingleton(serviceProvider => { var objectFactory = new Allors.Workspace.ObjectFactory(Allors.Workspace.Meta.MetaPopulation.Instance, typeof(Allors.Workspace.Domain.User)); var workspace = new Allors.Workspace.Workspace(objectFactory); return(workspace); }); // Server Side Blazor doesn't register HttpClient by default if (services.All(x => x.ServiceType != typeof(HttpClient))) { // Setup HttpClient for server side in a client side compatible fashion services.AddScoped(s => { // Creating the NavigationManager needs to wait until the JS Runtime is initialized, so defer it. var navigationManager = s.GetRequiredService <NavigationManager>(); return(new HttpClient { BaseAddress = new Uri(navigationManager.BaseUri), }); }); } services.AddBootstrapCSS(); if (this.Environment.IsDevelopment()) { services.AddScoped <IImageService, LocalImageService>(); } else { services.AddScoped <IImageService, WeservImageService>(); } }