Exemple #1
0
        public LogEngine()
        {
            JsonConfigReader configReader = new JsonConfigReader(JsonConfigReader.ConfigFileName);

            Require.NotNull(configReader, nameof(configReader));

            Console.WriteLine("data reading from config file");
            var connectionString = configReader.GetConnectionString("ApacheLogs");

            _filePath          = configReader.GetValue <string>("FilePath");
            _accessKey         = configReader.GetValue <string>("AccessKey");
            _counterForSave    = configReader.GetValue <int>("CounterForSave");
            _outerIpServiceUrl = configReader.GetValue <string>("OuterIpServiceUrl");
            _httpClient        = new InnerHttpClient();

            Require.NotEmpty(connectionString, () => $"{connectionString} should be specified in the appsettings.json file");
            Require.NotNull(_httpClient, nameof(_httpClient));
            Require.NotEmpty(_filePath, "'FilePath' should be specified in the appsettings.json file");
            Require.NotEmpty(_accessKey, "'AccessKey' should be specified in the appsettings.json file");
            Require.NotEmpty(_outerIpServiceUrl, "'OuterIpServiceUrl' should be specified in the appsettings.json file");
            Require.IsTrue(_counterForSave > 0, "'CounterForSave' should be specified in the appsettings.json file");

            Console.WriteLine("data base connecting");

            var optionsBuilder = new DbContextOptionsBuilder <ApacheLogDbContext>();

            optionsBuilder.UseSqlServer(connectionString);
            DbContextOptions <ApacheLogDbContext> options = optionsBuilder.Options;

            _context = new ApacheLogDbContext(options);
            Require.NotNull(_context, nameof(_context));

            _context.Initialize();
        }
Exemple #2
0
        public void DoubleParseTest()
        {
            IConfigReader cfgReader = new JsonConfigReader(SampleCfg);

            var value = cfgReader.GetValue <double>("TestDouble");

            Assert.AreEqual(1.1, value);
        }
Exemple #3
0
        public void IntParseTest()
        {
            IConfigReader cfgReader = new JsonConfigReader(SampleCfg);

            var value = cfgReader.GetValue <int>("TestInt");

            Assert.AreEqual(1, value);
        }
Exemple #4
0
        public void BasicTest()
        {
            IConfigReader cfgReader = new JsonConfigReader(SampleCfg);

            var value = cfgReader.GetValue <string>("TestKey");

            Assert.AreEqual("TestValue", value);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            Console.WriteLine(
                $"Noobot.Core assembly version: {Assembly.GetAssembly(typeof(INoobotCore)).GetName().Version}");
            var host = new NoobotHost(JsonConfigReader.ForAbsolutePath($"{AppDomain.CurrentDomain.BaseDirectory}/Configuration/config.json"));

            host.Start();
            _quitEvent.WaitOne();
        }
        public void should_read_config()
        {
            // given
            var reader = new JsonConfigReader();

            // when
            string slackKey = reader.SlackApiKey;

            // then
            slackKey.ShouldNotBeNull();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Reading appsettings.json from .Net Core Console..." + Environment.NewLine);

            var jsonConfigReader = new JsonConfigReader();
            var config           = jsonConfigReader.ReadPaymentsConfig();

            Console.WriteLine($"Username :{config.Credentials.Username}, Password : {config.Credentials.Password}");
            Console.WriteLine($"Url :{config.Service.Url}");

            Console.ReadLine();
        }
        public async Task should_connect_as_expected()
        {
            // given
            var configReader  = JsonConfigReader.DefaultLocation();
            var containerStub = new NoobotContainerStub();
            var connector     = new NoobotCore(configReader, new EmptyLogger(), containerStub);

            // when
            await connector.Connect();

            // then
        }
Exemple #9
0
        private static async Task RunNoobot()
        {
            var containerFactory = new ContainerFactory(
                new ConfigurationBase(),
                JsonConfigReader.DefaultLocation(),
                GetLogger());

            INoobotContainer container = containerFactory.CreateContainer();

            _noobotCore = container.GetNoobotCore();

            await _noobotCore.Connect();
        }
Exemple #10
0
        static void Main()
        {
            var configPath              = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "configuration/config.json");
            var jsonConfigReader        = new JsonConfigReader(configPath);
            var middleWareConfiguration = new NoobotDemoConfiguration();

            var noobotCore = Bootstrapper.SetupNoobotCore(jsonConfigReader, middleWareConfiguration);

            var noobotHost = new NoobotHost(noobotCore);

            noobotHost.Start();

            Console.Read();
        }
Exemple #11
0
        public void EnumerableTest()
        {
            List <KeyValuePair <string, string> > excepted = new Dictionary <string, string>
            {
                { "TestKey", "TestValue" },
                { "TestInt", "1" },
                { "TestDouble", "1.1" }
            }.ToList();
            IConfigReader cfgReader = new JsonConfigReader(SampleCfg);

            List <KeyValuePair <string, string> > actual = cfgReader.ToList();

            CollectionAssert.AreEquivalent(excepted, actual);
        }
        static void Main(string[] args)
        {
            Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "production");

            Console.WriteLine("Reading appsettings.json from .Net Framework Console..." + Environment.NewLine);

            var jsonConfigReader = new JsonConfigReader();
            var config           = jsonConfigReader.ReadPaymentsConfig();

            Console.WriteLine($"Username :{config.Credentials.Username}, Password : {config.Credentials.Password}");
            Console.WriteLine($"Url :{config.Service.Url}");

            Console.ReadLine();
        }
Exemple #13
0
        public void TestReadConfig()
        {
            var parameters = ConfigParams.FromTuples(
                "param1", "Test Param 1",
                "param2", "Test Param 2");

            ConfigParams config = JsonConfigReader.ReadConfig(null, "../../../../data/config.json", parameters);

            Assert.Equal(9, config.Count);
            Assert.Equal(123, config.GetAsInteger("field1.field11"));
            Assert.Equal("ABC", config.GetAsString("field1.field12"));
            Assert.Equal(123, config.GetAsInteger("field2.0"));
            Assert.Equal("ABC", config.GetAsString("field2.1"));
            Assert.Equal(543, config.GetAsInteger("field2.2.field21"));
            Assert.Equal("XYZ", config.GetAsString("field2.2.field22"));
            Assert.Equal(true, config.GetAsBoolean("field3"));
        }
Exemple #14
0
        public static ContainerConfig ReadFromJsonFile(string correlationId, string path)
        {
            var config = JsonConfigReader.ReadConfig(correlationId, path);

            return(ContainerConfig.FromConfig(config));
        }