Ejemplo n.º 1
0
        public override void ConfigureServices(WebHostBuilderContext context, IServiceCollection services)
        {
            services.AddServerSideBlazor();

            var optionsBuilder = services.AddOptions();

            optionsBuilder.AddOptions <SeoConfiguration>("BlazorDemo");


            services.AddScoped <HttpClient>(serviceProvider => serviceProvider.GetService <IHttpClientFactory>().CreateClient());

            services.AddScoped <IContosoRetailDataProvider, ContosoRetailDataProvider>();
            services.AddScoped <IRentInfoDataProvider, RentInfoDataProvider>();

            services.AddDbContext <FMRDemoContext>(options => {
                var connectionString = ConnectionStringUtils.GetGridLargeDataConnectionString(context.Configuration);
                if (connectionString != null)
                {
                    options.UseSqlServer(connectionString);
                }
            });

            services.AddDbContext <ContosoRetailContext>(options => {
                var connectionString = ConnectionStringUtils.GetPivotGridLargeDataConnectionString(context.Configuration);
                if (connectionString != null)
                {
                    options.UseSqlServer(connectionString);
                }
            });
        }
Ejemplo n.º 2
0
 public override Task <IObservable <int> > GetLoadingStateAsync()
 {
     if (ConnectionStringUtils.GetGridLargeDataConnectionString(Configuration) == null)
     {
         return(Task.FromResult <IObservable <int> >(null));
     }
     return(base.GetLoadingStateAsync());
 }
Ejemplo n.º 3
0
        public override void ConfigureServices(WebHostBuilderContext context, IServiceCollection services)
        {
#if DEBUG
            bool detailedErrors = true;
#else
            bool detailedErrors = Configuration.GetValue("detailedErrors", false);
#endif
            services.AddServerSideBlazor().AddCircuitOptions(x => x.DetailedErrors = detailedErrors);

            var optionsBuilder = services.AddOptions();
            optionsBuilder.AddOptions <DemoConfigurationData>("BlazorDemo");

            services.AddDevExpressBlazorWasmMasks();

            services.AddSingleton <IDemoVersion, DemoVersion>(x => {
                string customVersion = Configuration.GetValue <string>("dxversion");
                if (!string.IsNullOrEmpty(customVersion))
                {
                    customVersion = " " + customVersion.TrimStart();
                }
                var dxVersion = new Version(AssemblyInfo.Version);
                return(new DemoVersion(new Version(dxVersion.Major, dxVersion.Minor, dxVersion.Build) + customVersion));
            });
            services.AddScoped <HttpClient>(serviceProvider => serviceProvider.GetService <IHttpClientFactory>().CreateClient());

            services.AddScoped <IContosoRetailDataProvider, ContosoRetailDataProvider>();
            services.AddScoped <IRentInfoDataProvider, RentInfoDataProvider>();

            services.AddDbContextFactory <NorthwindContext>(opt => {
                var connectionString = ConnectionStringUtils.GetNorthwindConnectionString(context.Configuration);
                if (!string.IsNullOrEmpty(connectionString))
                {
                    opt.UseSqlServer(connectionString);
                }
                else
                {
                    opt.UseSqlite(ConnectionStringUtils.GetNorthwindSqliteConnectionString(context.Configuration));
                }
            });
            services.AddDbContextFactory <IssuesContext>(opt => {
                var connectionString = ConnectionStringUtils.GetIssuesConnectionString(context.Configuration);
                if (!string.IsNullOrEmpty(connectionString))
                {
                    opt.UseSqlServer(connectionString);
                }
                else
                {
                    opt.UseSqlite(ConnectionStringUtils.GetIssuesSqliteConnectionString(context.Configuration));
                }
            });
            services.AddDbContextFactory <WorldcitiesContext>(opt => {
                var connectionString = ConnectionStringUtils.GetWorlcitiesConnectionString(context.Configuration);
                if (!string.IsNullOrEmpty(connectionString))
                {
                    opt.UseSqlServer(connectionString);
                }
                else
                {
                    opt.UseSqlite(ConnectionStringUtils.GetWorlcitiesSqliteConnectionString(context.Configuration));
                }
            });
            services.AddDbContextFactory <RentInfoContext>(opt => {
                var connectionString = ConnectionStringUtils.GetGridLargeDataConnectionString(context.Configuration);
                if (!string.IsNullOrEmpty(connectionString))
                {
                    opt.UseSqlServer(connectionString);
                }
            });
            services.AddDbContextFactory <ContosoRetailContext>(opt => {
                var connectionString = ConnectionStringUtils.GetPivotGridLargeDataConnectionString(context.Configuration);
                if (!string.IsNullOrEmpty(connectionString))
                {
                    opt.UseSqlServer(connectionString);
                }
            });
        }