/// <summary> /// Add services required to host the server-side /// data portal. /// </summary> /// <param name="builder"></param> /// <param name="options"></param> public static DataPortalClientOptions AddServerSideDataPortal(this DataPortalClientOptions builder, Action <DataPortalServerOptions> options) { var opt = builder.DataPortalServerOptions; options?.Invoke(opt); var services = builder.Services; services.TryAddScoped(typeof(IAuthorizeDataPortal), opt.AuthorizerProviderType); foreach (Type interceptorType in opt.InterceptorProviders) { services.AddScoped(typeof(IInterceptDataPortal), interceptorType); } // services.TryAddScoped((p) => opt.InterceptorProviders); services.TryAddScoped(typeof(IObjectFactoryLoader), opt.ObjectFactoryLoaderType); services.TryAddScoped(typeof(IDataPortalActivator), opt.ActivatorType); services.TryAddScoped(typeof(IDataPortalExceptionInspector), opt.ExceptionInspectorType); services.TryAddScoped <DataPortalExceptionHandler>(); services.TryAddTransient(typeof(IDataPortalServer), typeof(DataPortal)); services.TryAddScoped <InterceptorManager>(); services.TryAddTransient <DataPortalSelector>(); services.TryAddTransient <SimpleDataPortal>(); services.TryAddTransient <FactoryDataPortal>(); services.TryAddTransient <DataPortalBroker>(); services.TryAddSingleton(typeof(Server.Dashboard.IDashboard), typeof(Server.Dashboard.NullDashboard)); return(builder); }
/// <summary> /// Configure data portal client to use LocalProxy. /// </summary> /// <param name="config">CslaDataPortalConfiguration object</param> /// <param name="options">Data portal proxy options</param> public static DataPortalClientOptions UseLocalProxy(this DataPortalClientOptions config, Action <LocalProxyOptions> options) { var existingOptions = config.Services.Where(i => i.ServiceType.Equals(typeof(IDataPortalProxy))).FirstOrDefault(); if (existingOptions?.ImplementationInstance is not LocalProxyOptions proxyOptions) { proxyOptions = new LocalProxyOptions(); } options?.Invoke(proxyOptions); config.Services.AddTransient <IDataPortalProxy, LocalProxy>(); config.Services.AddTransient((p) => proxyOptions); return(config); }
/// <summary> /// Configure data portal client to use RabbitMqProxy. /// </summary> /// <param name="config">CslaDataPortalConfiguration object</param> /// <param name="options">Data portal proxy options</param> public static DataPortalClientOptions UseHttpProxy( this DataPortalClientOptions config, Action <Csla.Channels.RabbitMq.RabbitMqProxyOptions> options) { var proxyOptions = new Csla.Channels.RabbitMq.RabbitMqProxyOptions(); options?.Invoke(proxyOptions); config.Services.AddTransient(typeof(IDataPortalProxy), sp => { var applicationContext = sp.GetRequiredService <ApplicationContext>(); return(new Csla.Channels.RabbitMq.RabbitMqProxy(applicationContext, proxyOptions)); }); return(config); }
/// <summary> /// Configure data portal client to use GrpcProxy. /// </summary> /// <param name="config">CslaDataPortalConfiguration object</param> /// <param name="options">Data portal proxy options</param> public static DataPortalClientOptions UseHttpProxy( this DataPortalClientOptions config, Action <Csla.Channels.Grpc.GrpcProxyOptions> options) { var proxyOptions = new Csla.Channels.Grpc.GrpcProxyOptions(); options?.Invoke(proxyOptions); config.Services.AddTransient(typeof(IDataPortalProxy), sp => { var applicationContext = sp.GetRequiredService <ApplicationContext>(); var channel = GrpcChannel.ForAddress(proxyOptions.DataPortalUrl); return(new Csla.Channels.Grpc.GrpcProxy(applicationContext, channel, proxyOptions)); }); return(config); }
/// <summary> /// Creates an instance of the type. /// </summary> /// <param name="services">Service collection</param> public CslaOptions(IServiceCollection services) { Services = services; DataPortalClientOptions = new DataPortalClientOptions(this); }
/// <summary> /// Add services required to host the server-side /// data portal. /// </summary> /// <param name="builder"></param> public static DataPortalClientOptions AddServerSideDataPortal(this DataPortalClientOptions builder) { return(AddServerSideDataPortal(builder, null)); }
/// <summary> /// Add services required to host the server-side /// data portal. /// </summary> /// <param name="config">The configuration that is to be affected</param> /// <param name="options">The action that is to be used to influence the configuration options</param> public static DataPortalClientOptions AddServerSideDataPortal(this DataPortalClientOptions config, Action <DataPortalServerOptions> options) { options?.Invoke(config.ServerOptions); return(config); }
/// <summary> /// Add services required to host the server-side /// data portal. /// </summary> /// <param name="config">The configuration that is to be affected</param> public static DataPortalClientOptions AddServerSideDataPortal(this DataPortalClientOptions config) { return(AddServerSideDataPortal(config, null)); }
/// <summary> /// Configure data portal client to use LocalProxy. /// </summary> /// <param name="config">CslaDataPortalConfiguration object</param> public static DataPortalClientOptions UseLocalProxy(this DataPortalClientOptions config) { return(UseLocalProxy(config, null)); }