Beispiel #1
0
        /// <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();
        }
Beispiel #2
0
        /// <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();
        }