public ConfigSource AddChild(string childName) { if (String.IsNullOrEmpty(childName)) { throw new ArgumentNullException("childName"); } int index = childName.IndexOf('.'); if (index != -1) { string parentName = childName.Substring(0, index); childName = childName.Substring(index + 1); ConfigSource configChild = GetChild(parentName); if (configChild == null) { configChild = AddChild(parentName); } return(configChild.AddChild(childName)); } ConfigSource child = new ConfigSource(this, childName); children.Add(child); return(child); }
public void AddChild() { ConfigSource config = new ConfigSource(); ConfigSource child = config.AddChild("test"); Assert.IsNotNull(child); Assert.AreEqual(1, config.ChildCount); Assert.AreEqual("test", child.Name); }
public void GetChildValue() { ConfigSource config = new ConfigSource(); ConfigSource child = config.AddChild("test.child"); child.SetValue("value", 32); int value = config.GetInt32("test.child.value"); Assert.AreEqual(32, value); }