/// <summary> /// Add CSLA .NET services for use by the application. /// </summary> /// <param name="services">ServiceCollection object</param> /// <param name="config">Implement to configure CSLA .NET</param> public static ICslaBuilder AddCsla(this IServiceCollection services, Action <CslaConfiguration> config) { ApplicationContext.SetServiceCollection(services); services.AddTransient(typeof(IDataPortal <>), typeof(DataPortal <>)); config?.Invoke(CslaConfiguration.Configure()); return(new CslaBuilder(services)); }
/// <summary> /// Add CSLA .NET services for use by the application. /// </summary> /// <param name="services">ServiceCollection object</param> /// <param name="options">Options for configuring CSLA .NET</param> public static IServiceCollection AddCsla(this IServiceCollection services, Action <CslaConfiguration> options) { // Custom configuration var cslaOptions = new CslaConfiguration(services); options?.Invoke(cslaOptions); // ApplicationContext defaults services.AddScoped <ApplicationContext>(); RegisterContextManager(services); // Data portal API defaults services.TryAddTransient(typeof(IDataPortal <>), typeof(DataPortal <>)); services.TryAddTransient(typeof(IChildDataPortal <>), typeof(DataPortal <>)); // LocalProxy is always necessary to support RunLocal services.TryAddTransient((p) => new Channels.Local.LocalProxyOptions()); services.AddTransient <Channels.Local.LocalProxy, Channels.Local.LocalProxy>(); // Server-side data portal is always necessary to support RunLocal cslaOptions.DataPortal().AddServerSideDataPortal(); // Default to using LocalProxy and local data portal var proxyInit = services.Where(i => i.ServiceType.Equals(typeof(IDataPortalProxy))).Any(); if (!proxyInit) { cslaOptions.DataPortal().UseLocalProxy(); } return(services); }
/// <summary> /// Configures the application to use CSLA .NET /// </summary> /// <param name="app">ApplicationBuilder object</param> /// <param name="config">Implement to configure CSLA .NET</param> public static IApplicationBuilder UseCsla( this IApplicationBuilder app, Action <CslaConfiguration> config) { ApplicationContext.DefaultServiceProvider = app.ApplicationServices; config?.Invoke(CslaConfiguration.Configure()); return(app); }
/// <summary> /// Configures the application to use CSLA .NET /// </summary> /// <param name="builder">IHostBuilder instance</param> /// <param name="config">Implement to configure CSLA .NET</param> public static HostBuilder UseCsla( this HostBuilder builder, Action <CslaConfiguration> config) { CslaConfiguration.Configure(). ContextManager(typeof(Csla.Windows.ApplicationContextManager)); config?.Invoke(CslaConfiguration.Configure()); return(builder); }
/// <summary> /// Add CSLA .NET services for use by the application. /// </summary> /// <param name="services">ServiceCollection object</param> /// <param name="config">Implement to configure CSLA .NET</param> public static ICslaBuilder AddCsla(this IServiceCollection services, Action <CslaConfiguration> config) { services.TryAddScoped <ApplicationContext>(); services.TryAddScoped(typeof(Core.IContextManager), typeof(Core.ApplicationContextManager)); services.TryAddTransient(typeof(IDataPortal <>), typeof(DataPortal <>)); config?.Invoke(CslaConfiguration.Configure()); return(new CslaBuilder(services)); }
/// <summary> /// Configures the application to use CSLA .NET /// </summary> /// <param name="app">ApplicationBuilder object</param> /// <param name="config">Implement to configure CSLA .NET</param> public static IComponentsApplicationBuilder UseCsla( this IComponentsApplicationBuilder app, Action <CslaConfiguration> config) { CslaConfiguration.Configure(). ContextManager(typeof(Csla.Blazor.ApplicationContextManager)); config?.Invoke(CslaConfiguration.Configure()); return(app); }
/// <summary> /// Configures services to provide CSLA Blazor server support /// </summary> /// <param name="builder">ICslaBuilder instance</param> /// <returns></returns> public static ICslaBuilder WithBlazorServerSupport(this ICslaBuilder builder) { CslaConfiguration.Configure().DataPortal().AuthenticationType("Windows"); builder.Services.AddTransient(typeof(ViewModel <>), typeof(ViewModel <>)); builder.Services.AddSingleton <IAuthorizationPolicyProvider, CslaPermissionsPolicyProvider>(); builder.Services.AddSingleton <IAuthorizationHandler, CslaPermissionsHandler>(); return(builder); }
/// <summary> /// Configures the application to use CSLA .NET /// </summary> /// <param name="app">ApplicationBuilder object</param> /// <param name="config">Implement to configure CSLA .NET</param> public static IApplicationBuilder UseCsla( this IApplicationBuilder app, Action <CslaConfiguration> config) { ApplicationContext.DefaultServiceProvider = app.ApplicationServices; ApplicationContext.WebContextManager = new Csla.AspNetCore.ApplicationContextManager(app.ApplicationServices); config?.Invoke(CslaConfiguration.Configure()); return(app); }
/// <summary> /// Configures the application to use CSLA .NET /// </summary> /// <param name="builder">IWebAssemblyHostBuilder object</param> /// <param name="config">Implement to configure CSLA .NET</param> public static WebAssemblyHostBuilder UseCsla( this WebAssemblyHostBuilder builder, Action <CslaConfiguration> config) { builder.Services.AddCsla().WithBlazorClientSupport(); CslaConfiguration.Configure(). ContextManager(typeof(Csla.Blazor.ApplicationContextManager)); config?.Invoke(CslaConfiguration.Configure()); return(builder); }
/// <summary> /// Configures the application to use CSLA .NET /// </summary> /// <param name="builder">IHostBuilder instance</param> /// <param name="config">Implement to configure CSLA .NET</param> public static IHostBuilder UseCsla( this IHostBuilder builder, Action <CslaConfiguration> config) { builder.ConfigureServices(services => { services.TryAddScoped(typeof(Csla.Core.IContextManager), typeof(Csla.Windows.ApplicationContextManager)); }); config?.Invoke(CslaConfiguration.Configure()); return(builder); }
/// <summary> /// Configures the application to use CSLA .NET /// </summary> /// <param name="builder">IWebAssemblyHostBuilder object</param> /// <param name="config">Implement to configure CSLA .NET</param> public static WebAssemblyHostBuilder UseCsla( this WebAssemblyHostBuilder builder, Action <CslaConfiguration> config) { builder.Services.AddCsla(); builder.Services.AddTransient(typeof(ViewModel <>), typeof(ViewModel <>)); builder.Services.AddSingleton <IAuthorizationPolicyProvider, CslaPermissionsPolicyProvider>(); builder.Services.AddSingleton <IAuthorizationHandler, CslaPermissionsHandler>(); CslaConfiguration.Configure(). ContextManager(typeof(Csla.Blazor.ApplicationContextManager)); config?.Invoke(CslaConfiguration.Configure()); return(builder); }
/// <summary> /// Configures the application to use CSLA .NET /// in a Blazor WebAssembly runtime /// </summary> /// <param name="builder">IWebAssemblyHostBuilder object</param> /// <param name="config">Implement to configure CSLA .NET</param> public static WebAssemblyHostBuilder UseCsla( this WebAssemblyHostBuilder builder, Action <CslaConfiguration> config) { builder.Services.AddCsla(); DataPortalClient.HttpProxy.UseTextSerialization = true; builder.Services.TryAddTransient(typeof(ViewModel <>), typeof(ViewModel <>)); builder.Services.TryAddSingleton <IAuthorizationPolicyProvider, CslaPermissionsPolicyProvider>(); builder.Services.TryAddSingleton <IAuthorizationHandler, CslaPermissionsHandler>(); CslaConfiguration.Configure(). ContextManager(typeof(Csla.Core.ApplicationContextManagerStatic)); config?.Invoke(CslaConfiguration.Configure()); return(builder); }