コード例 #1
0
        public void SimpleProperties()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("test=passed");
            sb.AppendLine("me=spaced value");

            ConfigSource source = new ConfigSource();

            source.LoadProperties(GetStream(sb));

            Assert.AreEqual("test", source.Keys[0]);
            Assert.AreEqual("me", source.Keys[1]);
            Assert.AreEqual("passed", source.GetString("test"));
            Assert.AreEqual("spaced value", source.GetString("me"));
        }
コード例 #2
0
ファイル: ConfigSourceTest.cs プロジェクト: yuexiaoyun/cloudb
        public void TestString()
        {
            ConfigSource config = new ConfigSource();

            config.SetValue("key", "value");

            Assert.AreEqual("value", config.GetString("key"));
        }
コード例 #3
0
        private static void SetChildValues(Util.Properties properties, string prefix, ConfigSource config)
        {
            prefix += config.Name;

            foreach (string key in config.Keys)
            {
                string value = config.GetString(key, null);
                if (String.IsNullOrEmpty(value))
                {
                    continue;
                }

                properties.SetProperty(prefix + "." + key, value);
            }

            foreach (ConfigSource child in config.Children)
            {
                SetChildValues(properties, prefix, child);
            }
        }