示例#1
1
        static HalibutLimits()
        {
            #if NET40
            var settings = System.Configuration.ConfigurationManager.AppSettings;

            var fields = typeof (HalibutLimits).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
            foreach (var field in fields)
            {
                var value = settings.Get("Halibut." + field.Name);
                if (string.IsNullOrWhiteSpace(value)) continue;
                var time = TimeSpan.Parse(value);
                field.SetValue(null, time);
            }
            #else
            // should be able to use Directory.GetCurrentDirectory()
            // to get the working path, but the nunit test runner
            // runs from another directory. Go with dll location for now.
            var directory = Path.GetDirectoryName(new Uri(typeof(HalibutLimits).GetTypeInfo().Assembly.CodeBase).LocalPath);
            var builder = new ConfigurationBuilder();
            builder.SetBasePath(directory);
            builder.AddJsonFile("appsettings.json", optional: true);
            var halibutConfig = builder.Build();

            var fields = typeof(HalibutLimits).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
            foreach (var field in fields)
            {
                var value = halibutConfig["Halibut:" + field.Name];
                if (string.IsNullOrWhiteSpace(value)) continue;
                var time = TimeSpan.Parse(value);
                field.SetValue(null, time);
            }
            #endif
        }
示例#2
0
        public Startup(IApplicationEnvironment env)
        {
            var builder = new ConfigurationBuilder();
            builder.SetBasePath(env.ApplicationBasePath);
            builder.AddEnvironmentVariables();

            Configuration = builder.Build();
        }
示例#3
0
 public Startup(IHostingEnvironment env, IApplicationEnvironment app)
 {
     ConfigurationBuilder builder = new ConfigurationBuilder();
     builder.SetBasePath(app.ApplicationBasePath);
     builder.AddJsonFile("appsettings.json");
     IConfigurationRoot config = builder.Build();
     AppSettings.ConnectionString = config.Get<string>
            ("Data:DefaultConnection:ConnectionString");
 }
示例#4
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder();

            builder.SetBasePath(env.ContentRootPath)
            .AddJsonFile("configuration.json", optional: false, reloadOnChange: true)
            .AddEnvironmentVariables();
            Configuration = builder.Build();
        }
示例#5
0
        private static IConfiguration ConfigureConfiguration(IHostingEnvironment hostingEnvironment)
        {
            IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
            configurationBuilder.SetBasePath(hostingEnvironment.ContentRootPath);
            configurationBuilder.AddJsonFile("config.json", optional: true);
            configurationBuilder.AddEnvironmentVariables();

            return configurationBuilder.Build();
        }
示例#6
0
 private static IConfigurationRoot GetConfigurationRoot()
 {
     var builder = new ConfigurationBuilder();
     var testFolder = new DirectoryInfo(Directory.GetCurrentDirectory()).FullName;
     builder.SetBasePath(testFolder);
     //use json file to configure settings. See http://docs.asp.net/en/latest/fundamentals/configuration.html for more detail on CongifurationBuilder
     builder.AddJsonFile("appsettings.json");
     var config = builder.Build();
     return config;
 }
示例#7
0
        public static void Main(string[] args)
        {
            Microsoft.Extensions.Configuration.ConfigurationBuilder bconfig = (Microsoft.Extensions.Configuration.ConfigurationBuilder)(new Microsoft.Extensions.Configuration.ConfigurationBuilder());
            //if (args != null)bconfig.AddCommandLine(args).Build();
            bconfig.SetBasePath(BasePath);
            bconfig.AddJsonFile(AppName + ".json", optional: true, reloadOnChange: true);
            _Config = bconfig.Build();

            Start(args);
            Config_OnChanged = Config.GetReloadToken().RegisterChangeCallback(Call_Config_OnChanged, new object[] { Config });
        }
示例#8
0
        public Startup(IHostingEnvironment environment)
        {
            var builder = new ConfigurationBuilder();

            builder.SetBasePath(environment.ContentRootPath)
            .AddJsonFile("appsettings.json", false, true)
            .AddJsonFile("configuration.json", false, true)
            .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
示例#9
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder();

            builder.SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json", true, true)
            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", true, true)
            .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
示例#10
0
        public Startup(Microsoft.AspNetCore.Hosting.IWebHostEnvironment env)
        {
            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder();

            builder.SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json")
            //add configuration.json
            .AddJsonFile("configuration.json", optional: false, reloadOnChange: true)
            .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
示例#11
0
        /// <summary>
        /// get IConfigurationRoot from rpclite.config.json
        /// </summary>
        /// <param name="basePath"></param>
        /// <returns></returns>
        public static IConfigurationRoot GetConfiguration(string basePath)
        {
            var configBuilder = new ConfigurationBuilder();

            if (!string.IsNullOrWhiteSpace(basePath))
                configBuilder.SetBasePath(basePath);

            configBuilder
                .AddJsonFile("rpclite.config.json", true);

            var config = configBuilder.Build();
            return config;
        }
示例#12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

            services.AddSingleton <HttpClient>();

            var configurationBuilder = new Microsoft.Extensions.Configuration.ConfigurationBuilder();

            configurationBuilder.SetBasePath(_env.ContentRootPath);
            configurationBuilder.AddJsonFile("urls.json");
            configurationBuilder.AddJsonFile("appsettings.json");
            var config       = configurationBuilder.Build();
            var gameStateUrl = config.GetSection("urls")["GameStateApi"];

            services.AddOptions();
            services.Configure <DemoOptions>(config);
            services.Configure <GameDuration>(config);

            services.AddSingleton <IGameStateClient, NullGameClient>();
            services.AddTransient <INewGameFactory, HardCodedGameFactory>();
            services.AddTransient <INewRegionsFactory, HardCodedRegionsFactory>();

            services.AddSignalR(
                o =>
            {
                o.Hubs.EnableDetailedErrors = true;
            });

            services.AddSingleton <ActorSystem>(
                x =>
            {
                var system = ActorSystem.Create("BlockWars");
                system.AddDependencyResolver(new ActorContainer(x, system));
                return(system);
            });

            services.AddSingleton <IServerManager, AkkaAdapter>();
            services.AddTransient <AccomplishmentManager, AccomplishmentManager>();

            services.AddTransient <GameActor, GameActor>();
            services.AddSingleton <ServerSupervisor, ServerSupervisor>();
            services.AddSingleton <Broadcaster, Broadcaster>();
            services.AddTransient <DemoActor, DemoActor>();
            services.AddTransient <GamePersistenceActor, GamePersistenceActor>();
            services.AddTransient <PlayerStatsActor, PlayerStatsActor>();
            services.AddSingleton <PlayerSupervisor, PlayerSupervisor>();
            services.AddTransient <PlayerActor, PlayerActor>();
            services.AddSingleton <LeaderboardActor, LeaderboardActor>();
            services.AddSingleton <LeaderboardBuffer, LeaderboardBuffer>();
        }
示例#13
0
        public Startup(IHostingEnvironment env, ILogger <Startup> logger)
        {
            _logger = logger;
            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder();

            builder.SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json")
            //add configuration.json
            .AddJsonFile("configuration.json", optional: false, reloadOnChange: true)
            .AddEnvironmentVariables();

            Configuration = builder.Build();

            _logger.LogInformation("Inside Gateway after Startup");
        }
示例#14
0
        public Startup(IApplicationEnvironment app, ILoggerFactory factory)
        {
            var jsonConfig = new JsonConfigurationProvider("config.json");
            var environConfig = new EnvironmentVariablesConfigurationProvider();

            var builder = new ConfigurationBuilder();
            builder.Add(jsonConfig);
            builder.Add(environConfig);
            builder.SetBasePath(app.ApplicationBasePath);

            Configuration = builder.Build();
            Environment = app;

            Factory = factory;
        }
示例#15
0
文件: Startup.cs 项目: levan0106/Blue
        public Startup(IHostingEnvironment env)
        {
            string CONFIGURATION = "configuration.json";

            CONFIGURATION = "configuration_dev.json";

            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder();

            builder.SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json")
            //add configuration.json
            .AddJsonFile(CONFIGURATION, optional: false, reloadOnChange: true)
            .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
示例#16
0
        public Startup(IWebHostEnvironment env)
        {
            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder();

            builder.SetBasePath(env.ContentRootPath)
            //add configuration.json
            .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)        // Duplicate == Json1
            .AddJsonFile("resources.json", optional: false, reloadOnChange: true)
            .AddEnvironmentVariables();

            Configuration = builder.Build();

            if (string.IsNullOrWhiteSpace(env.WebRootPath))
            {
                env.WebRootPath = Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\..\\UI\\SimpleERP.UI.Web", "wwwroot");
            }
        }
示例#17
0
        /// <summary>
        /// Start Up
        /// </summary>
        /// <param name="env">Host Environment</param>
        public Startup(IHostingEnvironment env)
        {
            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder();

            builder.SetBasePath(env.ContentRootPath)
            .AddJsonFile($"appsettings.json")
            .AddJsonFile("configuration.json", optional: false, reloadOnChange: true)
            .AddEnvironmentVariables();

            NLog.LogManager.LoadConfiguration(Path.Combine(env.ContentRootPath, "nlog.config")); // For Logging
            Configuration = builder.Build();

            //For Limit of calls or whilelisting and other features changes done in Configuration file
            //For Logging refer the comments in this file

            //Quality of services changes done in Configuration
            //If the server does not response for 2 seconds, it will throw a timeout exception.
            //If the server throws a second exception, the server will not be accessible for five seconds
        }
示例#18
0
        private static IConfigurationRoot GetConfigurationRoot()
        {
            var builder = new ConfigurationBuilder();

            //in-memory
            SetConfigurationDefaults(builder);

            //json
            var dir = new DirectoryInfo(Directory.GetCurrentDirectory()).FullName;
            var settingsFile = Path.Combine(dir, "appsettings.json");
            builder.SetBasePath(dir);
            if (File.Exists(settingsFile))
            {
                builder.AddJsonFile("appsettings.json");
            }

            var config = builder.Build();
            return config;
        }
示例#19
0
        public static void Main()
        {
            // work with with a builder using multiple calls
            var builder = new ConfigurationBuilder();
            builder.SetBasePath(Directory.GetCurrentDirectory());
            builder.AddJsonFile("appsettings.json");
            var connectionStringConfig = builder.Build();

            // chain calls together as a fluent API
            var config = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json")
                .AddEntityFrameworkConfig(options =>
                    options.UseSqlServer(connectionStringConfig.GetConnectionString("DefaultConnection"))
                )
                .Build();

            Console.WriteLine("key1={0}", config["key1"]);
            Console.WriteLine("key2={0}", config["key2"]);
            Console.WriteLine("key3={0}", config["key3"]);
        }
示例#20
0
        /// <summary>
        /// Creates and configures the application configuration, where key value pair settings are stored. See
        /// http://docs.asp.net/en/latest/fundamentals/configuration.html
        /// http://weblog.west-wind.com/posts/2015/Jun/03/Strongly-typed-AppSettings-Configuration-in-ASPNET-5
        /// </summary>
        /// <param name="hostingEnvironment">The environment the application is running under. This can be Development,
        /// Staging or Production by default.</param>
        /// <returns>A collection of key value pair settings.</returns>
        private static IConfiguration ConfigureConfiguration(IHostingEnvironment hostingEnvironment)
        {
            IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.SetBasePath(hostingEnvironment.ContentRootPath);

            // Add configuration from the config.json file.
            configurationBuilder.AddJsonFile("config.json");

            // Add configuration from an optional config.development.json, config.staging.json or
            // config.production.json file, depending on the environment. These settings override the ones in the
            // config.json file.
            configurationBuilder.AddJsonFile($"config.{hostingEnvironment.EnvironmentName}.json", optional: true);

            if (hostingEnvironment.IsDevelopment())
            {
                // This reads the configuration keys from the secret store. This allows you to store connection strings
                // and other sensitive settings, so you don't have to check them into your source control provider.
                // Only use this in Development, it is not intended for Production use. See
                // http://go.microsoft.com/fwlink/?LinkID=532709 and
                // http://docs.asp.net/en/latest/security/app-secrets.html
                configurationBuilder.AddUserSecrets();
            }

            // Add configuration specific to the Development, Staging or Production environments. This config can
            // be stored on the machine being deployed to or if you are using Azure, in the cloud. These settings
            // override the ones in all of the above config files.
            // Note: To set environment variables for debugging navigate to:
            // Project Properties -> Debug Tab -> Environment Variables
            // Note: To get environment variables for the machine use the following command in PowerShell:
            // [System.Environment]::GetEnvironmentVariable("[VARIABLE_NAME]", [System.EnvironmentVariableTarget]::Machine)
            // Note: To set environment variables for the machine use the following command in PowerShell:
            // [System.Environment]::SetEnvironmentVariable("[VARIABLE_NAME]", "[VARIABLE_VALUE]", [System.EnvironmentVariableTarget]::Machine)
            // Note: Environment variables use a colon separator e.g. You can override the site title by creating a
            // variable named AppSettings:SiteTitle. See
            // http://docs.asp.net/en/latest/security/app-secrets.html
            configurationBuilder.AddEnvironmentVariables();

            return configurationBuilder.Build();
        }
示例#21
0
        public static void Main(string[] args)
        {
            var baseConfigBuilder = new ConfigurationBuilder();
            baseConfigBuilder.SetBasePath(Directory.GetCurrentDirectory());
            baseConfigBuilder.AddCommandLine(args);
            baseConfigBuilder.AddEnvironmentVariables();
            var configFile = baseConfigBuilder.Build()["config"];
            if (string.IsNullOrEmpty(configFile))
            {
                Console.WriteLine("No Config File");
                Console.WriteLine("Need Parameter \"--config path\"");
                return;
            }
            baseConfigBuilder.AddJsonFile(configFile, true, true);
            var baseConfig = baseConfigBuilder.Build();
            var logConfigFile = baseConfig["Data:LogConfig"];
            var notifyAppsConfigFile = baseConfig["Data:NotifyAppsConfig"];
            var appChannelConfigFile = baseConfig["Data:AppChannelConfig"];
            baseConfigBuilder
                .AddJsonFile(logConfigFile, true, true)
                .AddJsonFile(notifyAppsConfigFile, true, true)
                .AddJsonFile(appChannelConfigFile, true, true);
            Configuration = baseConfigBuilder.Build();

            //Nlog
            var nlogConfig = new NLog.Config.LoggingConfiguration();
            BahamutCommon.LoggerLoaderHelper.LoadLoggerToLoggingConfig(nlogConfig, Configuration, "Logger:fileLoggers");

            #if DEBUG
            BahamutCommon.LoggerLoaderHelper.AddConsoleLoggerToLogginConfig(nlogConfig);
            #endif
            LogManager.Configuration = nlogConfig;

            try
            {
                //CSServer
                var server = new ChicagoServer();
                Server = server;
                server.UseNetConfig(new NetConfigReader());
                server.UseServerConfig(new ServerConfigReader());
                server.UseLogger(new FileLogger(Configuration["ServerLog"]));
            #if DEBUG
                server.UseLogger(ConsoleLogger.Instance);
            #endif
                server.UseMessageRoute(new JsonRouteFilter());
                server.UseExtension(new BahamutUserValidationExtension());
                server.UseExtension(new SharelinkerValidateExtension());
                server.UseExtension(new BahamutAppValidateExtension());

                //NotificationCenter Extension
                var notificationExt = new NotificaionCenterExtension();
                server.UseExtension(notificationExt);
                server.UseExtension(new HeartBeatExtension());
                server.StartServer();
            #if DEBUG
                DebugConsole();
            #else
                Thread.Sleep(Timeout.Infinite);
            #endif
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("Chicago").Fatal(ex);
                throw;
            }
        }