CSharpTest.Net
Sections Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : Sections Property

Glossary Item Box

Retrieves a collection of named sections within the userSettings container

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property Sections As UserSettingsSubSectionCollection
C# 
public UserSettingsSubSectionCollection Sections {get;}

Example

Library/Library.Test/TestUserSettings.cs

C#Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NETCopy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys