/// <summary> /// Creates a subset configuration inside an existing configuration as a setting. /// </summary> /// <param name="configParent">The parent configuration</param> /// <param name="strIdentifier">The identifier of the setting.</param> /// <param name="iIndex">An index, if there is more than one setting available via the given /// <see cref="strIdentifier"/>.</param> public static njSubConfiguration CreateChild(this njAbstractConfiguration configParent, string strIdentifier, int iIndex = 0) { njSubConfiguration configSub = new njSubConfiguration(); configSub.LoadConfiguration(); configParent.Set(strIdentifier, configSub, iIndex); return(configSub); }
public void ReadSubConfig() { var config = OpenTestConfig("SubConfig.xml", false); config.LoadConfiguration(); Assert.IsTrue(config.IsValid); Assert.AreEqual(1, config.Count); njSubConfiguration configSub = config.Get <njSubConfiguration>("subconfig"); Assert.NotNull(configSub); Assert.IsTrue(configSub.IsValid); Assert.AreEqual(3, configSub.Count); Assert.AreEqual("first index", configSub.Get("item", "", 0), "Falscher Wert"); Assert.AreEqual("second index", configSub.Get("item", "", 1), "Falscher Wert"); Assert.AreEqual("third index", configSub.Get("item", "", 2), "Falscher Wert"); CloseTestConfig("SubConfig.xml", config); }
public void WriteSubConfig() { var config = OpenTestConfig("WriteSubConfig.xml", true); config.LoadConfiguration(); Assert.IsTrue(config.IsValid); Assert.AreEqual(0, config.Count); njSubConfiguration configSub = config.GetSubConfig("subconfig", 0); Assert.NotNull(configSub); Assert.IsTrue(configSub.IsValid); Assert.AreEqual(0, configSub.Count); configSub.Set("item", "first index", 0); configSub.Set("item", "second index", 1); configSub.Set("item", "third index", 2); CloseTestConfig("WriteSubConfig.xml", config); }