/// <summary> /// Deep copy of all settings from one configuration to another. /// </summary> public void CopyFrom(UserSettingsSubSectionCollection other) { foreach (UserSettingsSubSection from in other) { UserSettingsSubSection to = this[from.Name]; if (to == null) { to = this.Add(from.Name); } to.CopyFrom(from); } }
public void TestUserSettingsSectionCollection() { UserSettingsSubSection a; UserSettingsSubSectionCollection coll1 = new UserSettingsSubSectionCollection(); Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType); Assert.IsNull(coll1["a"]); a = coll1.Add("a"); Assert.AreEqual(a, coll1["a"]); coll1.Remove("a"); Assert.IsNull(coll1["a"]); a = coll1.Add("a"); Assert.AreEqual(a, coll1["a"]); coll1.Clear(); Assert.IsNull(coll1["a"]); a = coll1.Add("a"); Assert.AreEqual(a, coll1["a"]); UserSettingsSubSectionCollection other = new UserSettingsSubSectionCollection(); other.CopyFrom(coll1); Assert.IsNotNull(other["a"]); Assert.AreEqual("a", other["a"].Name); }
/// <summary> /// Deep copy of all settings from one configuration to another. /// </summary> public void CopyFrom(UserSettingsSubSectionCollection other) { foreach (UserSettingsSubSection from in other) { UserSettingsSubSection to = this[from.Name]; if (to == null) to = this.Add(from.Name); to.CopyFrom(from); } }