Пример #1
0
        public Startup(IConfiguration configuration, IHostingEnvironment env)
        {
            Configuration = configuration;
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            this.Configuration = builder.Build();
            BaseConfigModel.SetBaseConfig(Configuration, env.ContentRootPath, env.WebRootPath);
        }
Пример #2
0
        public Startup(IConfiguration configuration, IWebHostEnvironment env)
        {
            Configuration = configuration;
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          // .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true)
                          //.AddJsonFile("appsettings" + "." + env.EnvironmentName + ".json", optional: true, reloadOnChange: true);
            ;


            this.Configuration = builder.Build();
            BaseConfigModel.SetBaseConfig(Configuration, env.ContentRootPath, env.WebRootPath);
        }
Пример #3
0
        /// <summary></summary>
        /// <param name="configuration"></param>
        public Startup(IConfiguration configuration)
        {
            #region 读取配置文件

            var location = System.Reflection.Assembly.GetExecutingAssembly().Location;
            var applicationExeDirectory = Path.GetDirectoryName(location);
            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            IConfigurationRoot _Configuration = builder.Build();

            BaseConfigModel.SetBaseConfig(_Configuration);
            Configuration = configuration;

            #endregion 读取配置文件
        }
Пример #4
0
        public Startup(IHostingEnvironment env)
        {
            this._env = env;
            //Microsoft.Extensions.PlatformAbstractions.ApplicationEnvironment appEnvironment = PlatformServices.Default.Application;
            //string ContentRootPath = appEnvironment.ApplicationBasePath;
            //env.ContentRootPath = ContentRootPath;
            //env.WebRootPath = ContentRootPath;
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            this.Configuration = builder.Build();
            var test = Configuration.ToString();

            BaseConfigModel.SetBaseConfig(Configuration, env.ContentRootPath, env.WebRootPath);
        }
Пример #5
0
        public Startup(IConfiguration configuration, IWebHostEnvironment env)
        {
            config = configuration;

            BaseConfigModel.SetBaseConfig(config, env.ContentRootPath, env.WebRootPath);
        }