private HoconConfigurationProvider LoadProvider(string hocon)
        {
            var p = new HoconConfigurationProvider(new HoconConfigurationSource {
                Optional = true
            });

            p.Load(TestStreamHelpers.StringToStream(hocon));
            return(p);
        }
Exemple #2
0
        public void ArraysAreConvertedToKeyValuePairs()
        {
            var hocon = @"{
                'ip': [
                    '1.2.3.4',
                    '7.8.9.10',
                    '11.12.13.14'
                ]
            }";

            var hoconConfigSource = new HoconConfigurationProvider(new HoconConfigurationSource());

            hoconConfigSource.Load(TestStreamHelpers.StringToStream(hocon));

            Assert.Equal("1.2.3.4", hoconConfigSource.Get("ip:0"));
            Assert.Equal("7.8.9.10", hoconConfigSource.Get("ip:1"));
            Assert.Equal("11.12.13.14", hoconConfigSource.Get("ip:2"));
        }
Exemple #3
0
        public void NestedArrays()
        {
            var hocon = @"{
                'ip': [
                    [ 
                        '1.2.3.4',
                        '5.6.7.8'
                    ],
                    [ 
                        '9.10.11.12',
                        '13.14.15.16'
                    ],
                ]
            }";

            var hoconConfigSource = new HoconConfigurationProvider(new HoconConfigurationSource());

            hoconConfigSource.Load(TestStreamHelpers.StringToStream(hocon));

            Assert.Equal("1.2.3.4", hoconConfigSource.Get("ip:0:0"));
            Assert.Equal("5.6.7.8", hoconConfigSource.Get("ip:0:1"));
            Assert.Equal("9.10.11.12", hoconConfigSource.Get("ip:1:0"));
            Assert.Equal("13.14.15.16", hoconConfigSource.Get("ip:1:1"));
        }
Exemple #4
0
        public void ArrayOfObjects()
        {
            var hocon = @"{
                'ip': [
                    {
                        'address': '1.2.3.4',
                        'hidden': false
                    },
                    {
                        'address': '5.6.7.8',
                        'hidden': true
                    }
                ]
            }";

            var hoconConfigSource = new HoconConfigurationProvider(new HoconConfigurationSource());

            hoconConfigSource.Load(TestStreamHelpers.StringToStream(hocon));

            Assert.Equal("1.2.3.4", hoconConfigSource.Get("ip:0:address"));
            Assert.Equal("false", hoconConfigSource.Get("ip:0:hidden"));
            Assert.Equal("5.6.7.8", hoconConfigSource.Get("ip:1:address"));
            Assert.Equal("true", hoconConfigSource.Get("ip:1:hidden"));
        }