CSharpTest.Net
UserSettingStorage Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : UserSettingStorage Class

Glossary Item Box

Stores values in the local configuration section: "userSettings"

Syntax

Visual Basic (Declaration) 
Public Class UserSettingStorage 
   Inherits AppSettingStorage
   Implements CSharpTest.Net.Serialization.INameValueStore 
C# 
public class UserSettingStorage : AppSettingStorage, CSharpTest.Net.Serialization.INameValueStore  

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)

Inheritance Hierarchy

System.Object
   CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage
      CSharpTest.Net.Serialization.StorageClasses.UserSettingStorage

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys