CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.Blazor/ConfigurationExtensions.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="BlazorConfigurationExtensions.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Implement extension methods for .NET Core configuration</summary>
7//-----------------------------------------------------------------------
8using System;
9using Csla.Blazor;
10using Csla.Core;
11using Csla.Runtime;
12using Microsoft.AspNetCore.Authorization;
13using Microsoft.AspNetCore.Components.Authorization;
16
17namespace Csla.Configuration
18{
22 public static class BlazorConfigurationExtensions
23 {
29 public static CslaOptions AddServerSideBlazor(this CslaOptions config)
30 {
31 return AddServerSideBlazor(config, null);
32 }
33
40 public static CslaOptions AddServerSideBlazor(this CslaOptions config, Action<BlazorServerConfigurationOptions> options)
41 {
42 var blazorOptions = new BlazorServerConfigurationOptions();
43 options?.Invoke(blazorOptions);
44
45 // minimize PropertyChanged events
46 config.PropertyChangedMode(ApplicationContext.PropertyChangedModes.Windows);
47
48#if NET5_0_OR_GREATER
49 var managerType = Type.GetType("Csla.AspNetCore.Blazor.ApplicationContextManagerBlazor,Csla.AspNetCore");
50 if (managerType is null)
51 throw new TypeLoadException("Csla.AspNetCore.Blazor.ApplicationContextManagerBlazor,Csla.AspNetCore");
52 config.Services.AddScoped(typeof(IContextManager), managerType);
53#endif
54
55 // use Blazor viewmodel
56 config.Services.TryAddTransient(typeof(ViewModel<>), typeof(ViewModel<>));
57 if (blazorOptions.UseCslaPermissionsPolicy)
58 {
59 config.Services.AddTransient<IAuthorizationPolicyProvider, CslaPermissionsPolicyProvider>();
60 config.Services.AddTransient<IAuthorizationHandler, CslaPermissionsHandler>();
61 }
62 return config;
63 }
64 }
65
71 {
76 public bool UseCslaPermissionsPolicy { get; set; } = true;
77 }
78}
Authorization handler for CSLA permissions.
Base type for creating your own viewmodel.
Options that can be provided to the WithBlazorServerSupport method.
bool UseCslaPermissionsPolicy
Indicates whether the app should be configured to use CSLA permissions policies (default = true).
Defines the interface for an application context manager type.