CSharpTest.Net
CopyFrom Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSection Class : CopyFrom Method

other

Glossary Item Box

Deep copy of all settings from one configuration to another.

Syntax

Visual Basic (Declaration) 
Public Sub CopyFrom( _
   ByVal other As UserSettingsSubSection _
) 
C# 
public void CopyFrom( 
   UserSettingsSubSection other
)

Parameters

other

Example

Library/Library.Test/TestUserSettings.cs

C#Copy Code
UserSettingsSubSection section = new UserSettingsSubSection();

section.Name = "a";
Assert.AreEqual("a", section.Name);

Assert.IsNotNull(section.Settings);

Assert.IsNull(section["a"]);
section["a"] = "b";
Assert.AreEqual("b", section["a"]);
section["a"] = "c";
Assert.AreEqual("c", section["a"]);

UserSettingsSubSection section2 = new UserSettingsSubSection();
section2.Name = "b";
Assert.AreNotEqual(0, section.CompareTo(section2));
section2.Name = "a";
Assert.AreEqual(0, section.CompareTo(section2));

section["a"] = "b";
section.Settings.Add("hello", "world");
section2.Settings.Add("hello", "universe");
Assert.AreEqual("universe", section2["hello"]);

section2.CopyFrom(section);
Assert.AreEqual("b", section2["a"]);
Assert.AreEqual("world", section2["hello"]);
VB.NETCopy Code
Dim section As New UserSettingsSubSection()

section.Name = "a"
Assert.AreEqual("a", section.Name)

Assert.IsNotNull(section.Settings)

Assert.IsNull(section("a"))
section("a") = "b"
Assert.AreEqual("b", section("a"))
section("a") = "c"
Assert.AreEqual("c", section("a"))

Dim section2 As New UserSettingsSubSection()
section2.Name = "b"
Assert.AreNotEqual(0, section.CompareTo(section2))
section2.Name = "a"
Assert.AreEqual(0, section.CompareTo(section2))

section("a") = "b"
section.Settings.Add("hello", "world")
section2.Settings.Add("hello", "universe")
Assert.AreEqual("universe", section2("hello"))

section2.CopyFrom(section)
Assert.AreEqual("b", section2("a"))
Assert.AreEqual("world", section2("hello"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys