コード例 #1
0
ファイル: Globals.cs プロジェクト: wostling/FriendlyCosmosBot
        /// <summary>
        /// Initialize the global variables
        /// </summary>
        public static void InitGlobals()
        {
            // Set up configuration laoder
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddEnvironmentVariables();

            var configuration = builder.Build();

            NLog.LogManager.GetLogger("AstroBot.Globals").Info("Reading settings...");

            var botSettings = new Objects.Config.BotSettings();

            configuration.GetSection("BotSettings").Bind(botSettings);
            BotSettings = botSettings;

            var awesomeChatbotSettings = new AwesomeChatBot.AwesomeChatBotSettings();

            configuration.GetSection("AwesomeChatBotSettings").Bind(awesomeChatbotSettings);
            AwesomeChatBotSettings = awesomeChatbotSettings;

            // Create logger factory
            LoggerFactory = new LoggerFactory();
            LoggerFactory.AddNLog();
        }
コード例 #2
0
ファイル: Globals.cs プロジェクト: RononDex/Astrobot
        /// <summary>
        /// Initialize the global variables
        /// </summary>
        public static void InitGlobals()
        {
            // Set up configuration laoder
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddEnvironmentVariables();

            var configuration = builder.Build();

            NLog.LogManager.GetLogger("AstroBot.Globals").Info("Reading settings...");

            var botSettings = new Objects.Config.BotSettings();

            configuration.GetSection("BotSettings").Bind(botSettings);
            BotSettings = botSettings;

            var awesomeChatbotSettings = new AwesomeChatBot.AwesomeChatBotSettings();

            configuration.GetSection("AwesomeChatBotSettings").Bind(awesomeChatbotSettings);
            AwesomeChatBotSettings = awesomeChatbotSettings;


            SmallTalkReponsesConfig = JsonConvert.DeserializeObject <Root>(File.ReadAllText("smallTalkConfig.json"));
            Console.WriteLine($"Loaded {SmallTalkReponsesConfig.SmallTalkResponses.Count} small talk responses");

            // Create logger factory
            LoggerFactory = new LoggerFactory();
            LoggerFactory.AddNLog();
        }