当前位置: 首页>>代码示例>>C#>>正文


C# ConfigurationBuilder.AddUserSecrets方法代码示例

本文整理汇总了C#中Microsoft.Framework.Configuration.ConfigurationBuilder.AddUserSecrets方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationBuilder.AddUserSecrets方法的具体用法?C# ConfigurationBuilder.AddUserSecrets怎么用?C# ConfigurationBuilder.AddUserSecrets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Framework.Configuration.ConfigurationBuilder的用法示例。


在下文中一共展示了ConfigurationBuilder.AddUserSecrets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.

            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            if (env.IsDevelopment())
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();

                // todo: use Configuration with config.json instead of hardcoded URLs
                AppSettings["WeatherApiDomain"] = "http://localhost:60583";
            }
            else
            {
                AppSettings["WeatherApiDomain"] = "http://nws-wapi-staging.azurewebsites.net:80";
            }

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
开发者ID:johnsoaa,项目名称:weather-ui,代码行数:25,代码来源:Startup.cs

示例2: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddJsonFile("appsettings.json")
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            //appEnv.
            //env.EnvironmentName = "Development";

            if (env.IsEnvironment("Development"))
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();
            }

            // this file name is ignored by gitignore
            // so you can create it and use on your local dev machine
            // remember last config source added wins if it has the same settings
            builder.AddJsonFile("appsettings.local.overrides.json", optional: true);

            // most common use of environment variables would be in azure hosting
            // since it is added last anything in env vars would trump the same setting in previous config sources
            // so no risk of messing up settings if deploying a new version to azure
            builder.AddEnvironmentVariables();
            Configuration = builder.Build();

            //env.MapPath
        }
开发者ID:Tinkerc,项目名称:cloudscribe,代码行数:31,代码来源:Startup.cs

示例3: Startup

 public Startup(IApplicationEnvironment appEnv)
 {
     var configBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
     configBuilder.AddUserSecrets();
     configBuilder.AddEnvironmentVariables();
     _configuration = configBuilder.Build();
 }
开发者ID:glennc,项目名称:GHUtils,代码行数:7,代码来源:Startup.cs

示例4: Startup

 public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
 {
     var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
     builder.AddJsonFile("config.json");
     builder.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
     builder.AddUserSecrets();
     builder.AddEnvironmentVariables();
     Configuration = builder.Build();
 }
开发者ID:mequanta,项目名称:Janitor-old,代码行数:9,代码来源:Startup.cs

示例5: Startup

        public Startup(IApplicationEnvironment appEnv, IHostingEnvironment env)
        {
            var configBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json", optional: true);

            if (env.IsDevelopment())
            {
                configBuilder.AddUserSecrets();
            }

            configBuilder.AddEnvironmentVariables();
            Configuration = configBuilder.Build();
        }
开发者ID:moozzyk,项目名称:ToDoList,代码行数:13,代码来源:Startup.cs

示例6: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddEnvironmentVariables();

            if (env.IsDevelopment())
            {
                builder.AddUserSecrets();
            }

            Configuration = builder.Build();
        }
开发者ID:muratg,项目名称:ProjectKIssueList,代码行数:14,代码来源:Startup.cs

示例7: Startup

 public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
 {
     // Setup configuration sources.
     var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
         .AddJsonFile("config.json")
         .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
     // development via user-secret
     if (env.IsDevelopment())
     {
         builder.AddUserSecrets();
     }
     builder.AddEnvironmentVariables();
     Configuration = builder.Build();
 }
开发者ID:ZhangYueqiu,项目名称:asp5-mvc6-examples,代码行数:14,代码来源:Startup.cs

示例8: Startup

        public Startup(IHostingEnvironment env)
        {
            // Setup configuration sources.
            var configuration = new ConfigurationBuilder()
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            if (env.IsEnvironment("Development"))
            {
                configuration.AddUserSecrets();
            }
            configuration.AddEnvironmentVariables();
            Configuration = configuration.Build();
        }
开发者ID:dotnet18,项目名称:NerdDinner,代码行数:14,代码来源:Startup.cs

示例9: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.

            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath).AddJsonFile("config.json").AddJsonFile($"config.{env.EnvironmentName}.json", true);

            if (env.IsDevelopment())
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();
            }
            builder.AddEnvironmentVariables();
            this.Configuration = builder.Build();
        }
开发者ID:afmorris,项目名称:LadyColtSoccer.com,代码行数:15,代码来源:Startup.cs

示例10: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath);

            if (env.IsDevelopment())
            {
                builder.AddJsonFile("appsettings.json").AddJsonFile("privatesettings.json");
            }

            builder.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
            builder.AddUserSecrets();
            builder.AddEnvironmentVariables();
            this.Configuration = builder.Build();
        }
开发者ID:OsirisTerje,项目名称:musicstore-api-aspnet5,代码行数:15,代码来源:Startup.cs

示例11: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            DbMapping.Init();

            // Setup configuration sources.
            var configuration = new ConfigurationBuilder(appEnv.ApplicationBasePath);
            configuration.AddJsonFile("config.json");

            if (env.IsEnvironment("Development"))
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                configuration.AddUserSecrets();
            }
            configuration.AddEnvironmentVariables();
            Configuration = configuration.Build();
        }
开发者ID:akkgr,项目名称:yolo,代码行数:17,代码来源:Startup.cs

示例12: Startup

        public Startup(IHostingEnvironment env)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder(env.MapPath(@"..\"))
                .AddJsonFile("config.json", optional: true)
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            if (env.IsEnvironment("Development"))
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();

                builder.AddApplicationInsightsSettings(developerMode: true);
            }
            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
开发者ID:hackathonvixion,项目名称:ApplicationInsights-aspnet5,代码行数:18,代码来源:Startup.cs

示例13: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json", true)
                .AddJsonFile($"config.{env.EnvironmentName}.json", true);

            builder.AddUserSecrets();
            if (env.IsDevelopment())
            {
                // put ApplicationInsights in developer mode
                builder.AddApplicationInsightsSettings(true);
            }

            builder.AddEnvironmentVariables();

            Configuration = builder.Build();
        }
开发者ID:robpaveza,项目名称:Hawk,代码行数:18,代码来源:Startup.cs

示例14: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddEnvironmentVariables()
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            if (env.IsDevelopment())
            {
                // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
                builder.AddApplicationInsightsSettings(developerMode: true);
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();
            }
            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
开发者ID:kensaccord,项目名称:kkwedding,代码行数:18,代码来源:Startup.cs

示例15: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.

            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            if (env.IsDevelopment())
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();
            }
            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
            Configuration["Data:DefaultConnection:ConnectionString"] = [email protected]"Data Source={appEnv.ApplicationBasePath}/<%= namespace %>.db";
        }
开发者ID:shirhatti,项目名称:generator-aspnet,代码行数:18,代码来源:Startup.cs


注:本文中的Microsoft.Framework.Configuration.ConfigurationBuilder.AddUserSecrets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。