示例#1
0
        private static IConfiguration SetUpDefaultAssembly(string assemblyName)
        {
            var source = new MemoryConfigurationSource();

            source.Add("defaultAssembly", assemblyName);
            var config = new ConfigurationBuilder();

            config.Add(source);
            return(config.Build());
        }
        public SqlServerCacheWithDatabaseTest()
        {
            // TODO: Figure how to use config.json which requires resolving IApplicationEnvironment which currently
            // fails.
            var memoryConfigurationSource = new MemoryConfigurationSource();

            memoryConfigurationSource.Add(
                ConnectionStringKey,
                "Server=localhost;Database=CacheTestDb;Trusted_Connection=True;");
            memoryConfigurationSource.Add(SchemaNameKey, "dbo");
            memoryConfigurationSource.Add(TableNameKey, "CacheTest");

            var configurationBuilder = new ConfigurationBuilder();

            configurationBuilder
            .Add(memoryConfigurationSource)
            .AddEnvironmentVariables();

            var configuration = configurationBuilder.Build();

            _tableName        = configuration.Get(TableNameKey);
            _schemaName       = configuration.Get(SchemaNameKey);
            _connectionString = configuration.Get(ConnectionStringKey);
        }
        protected override void OnStart(string[] args)
        {
            var configSource = new MemoryConfigurationSource();
            configSource.Add("server.urls", "http://localhost:5000");

            var config = new ConfigurationBuilder(configSource).Build();
            var builder = new WebHostBuilder(_serviceProvider, config);
            builder.UseServer("Microsoft.AspNet.Server.Kestrel");
            builder.UseServices(services => services.AddMvc());
            builder.UseStartup(appBuilder =>
            {
                appBuilder.UseDefaultFiles();
                appBuilder.UseStaticFiles();
                appBuilder.UseMvc();
            });

            _hostingEngine = builder.Build();
            _shutdownServerDisposable = _hostingEngine.Start();
        }
 private static IConfiguration SetUpDefaultAssembly(string assemblyName)
 {
     var source = new MemoryConfigurationSource();
     source.Add("defaultAssembly", assemblyName);
     var config = new ConfigurationBuilder();
     config.Add(source);
     return config.Build();
 }