예제 #1
0
        /// <summary>
        /// Configures services to provide CSLA Blazor server support
        /// </summary>
        /// <param name="config">CslaOptions instance</param>
        /// <param name="options">Options object</param>
        /// <returns></returns>
        public static CslaOptions AddServerSideBlazor(this CslaOptions config, Action <BlazorServerConfigurationOptions> options)
        {
            var blazorOptions = new BlazorServerConfigurationOptions();

            options?.Invoke(blazorOptions);

            // minimize PropertyChanged events
            config.PropertyChangedMode(ApplicationContext.PropertyChangedModes.Windows);

#if NET5_0_OR_GREATER
            var managerType = Type.GetType("Csla.AspNetCore.Blazor.ApplicationContextManagerBlazor,Csla.AspNetCore");
            if (managerType is null)
            {
                throw new TypeLoadException("Csla.AspNetCore.Blazor.ApplicationContextManagerBlazor,Csla.AspNetCore");
            }
            config.Services.AddScoped(typeof(IContextManager), managerType);
#endif

            // use Blazor viewmodel
            config.Services.TryAddTransient(typeof(ViewModel <>), typeof(ViewModel <>));
            if (blazorOptions.UseCslaPermissionsPolicy)
            {
                config.Services.AddTransient <IAuthorizationPolicyProvider, CslaPermissionsPolicyProvider>();
                config.Services.AddTransient <IAuthorizationHandler, CslaPermissionsHandler>();
            }
            return(config);
        }
 /// <summary>
 /// Configures services to provide CSLA Blazor server support
 /// </summary>
 /// <param name="builder">ICslaBuilder instance</param>
 /// <param name="options">Options object</param>
 /// <returns></returns>
 public static ICslaBuilder WithBlazorServerSupport(this ICslaBuilder builder, BlazorServerConfigurationOptions options = null)
 {
     if (options == null)
     {
         options = new BlazorServerConfigurationOptions();
     }
     builder.Services.TryAddTransient(typeof(ViewModel <>), typeof(ViewModel <>));
     if (options.UseCslaPermissionsPolicy)
     {
         builder.Services.AddSingleton <IAuthorizationPolicyProvider, CslaPermissionsPolicyProvider>();
         builder.Services.AddSingleton <IAuthorizationHandler, CslaPermissionsHandler>();
     }
     return(builder);
 }
예제 #3
0
        /// <summary>
        /// Configures services to provide CSLA Blazor server support
        /// </summary>
        /// <param name="config">ICslaConfiguration instance</param>
        /// <param name="options">Options object</param>
        /// <returns></returns>
        public static ICslaConfiguration AddServerSideBlazor(this ICslaConfiguration config, Action <BlazorServerConfigurationOptions> options)
        {
            var blazorOptions = new BlazorServerConfigurationOptions();

            options?.Invoke(blazorOptions);

            // use Blazor viewmodel
            config.Services.TryAddTransient(typeof(ViewModel <>), typeof(ViewModel <>));
            if (blazorOptions.UseCslaPermissionsPolicy)
            {
                config.Services.AddTransient <IAuthorizationPolicyProvider, CslaPermissionsPolicyProvider>();
                config.Services.AddTransient <IAuthorizationHandler, CslaPermissionsHandler>();
            }
            return(config);
        }