the operation of the storage subsystem of user settings using the class SettingManager; specified as to include storage settings, what are the methods to be used for writing and reading settings

Enable subsystem settings

The subsystem is to implement saving the user preferences in the application.

Access to the system settings provided by the wizard, a set of static class methods ICSSoft.STORMNET.Settings.SettingManager.

In order to enable the subsystem settings, you need to install a static property ICSSoft.STORMNET.Settings.SettingManager.UseSettings in true. Also, you can do it in config file for an application, which requires to add the line:

<add key="UseSettings" value="True"/>	

Save your own settings

Saving settings is performed by the function SetSettings, read settings function GetSetting.

The settings indicated:

  • The name of the module that saved the settings. It’s just a logical name that allows you to set group settings. Hence, when any setting, actually read and cached all the settings for the module.
  • Name settings.
  • The setting value. Setting identificireba unique module name, setup name and user name. Username settings Manager recovers automatically.

Example (saving position and size of the form):

SettingManager.SetSetting("SettingsTest", "Form Position&Size", string.Join(",", new string[]{
					this.Left.ToString(),
					this.Top.ToString(),
					this.Width.ToString(),
					this.Height.ToString()
		}));

An example of (read the position and size of the form):

	string setting = SettingManager.GetSetting("SettingsTest", "Form Position&Size");
	if (setting!=null)
	{
		string[] splittedsetting = setting.Split(',');
		this.Left=int.Parse(splittedsetting[0]);
		this.Top=int.Parse(splittedsetting[1]);
		this.Width=int.Parse(splittedsetting[2]);
		this.Height=int.Parse(splittedsetting[3]);
	}

Serialization of data objects is performed in a different way: How the «spin» data object to an XML string and restore back.

Переведено сервисом «Яндекс.Переводчик» http://translate.yandex.ru