Exemplo n.º 1
0
		public void Load()
		{
			var map = new ExeConfigurationFileMap();
			map.ExeConfigFilename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
			string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), _appName);
#if DEBUG
			path = Path.Combine(path, string.Format("{0}.DEBUG.config", _appName));
#else
			path = Path.Combine(path, string.Format("{0}.config", _appName));
#endif
			this.IsFirstLaunch = !File.Exists(path);
			map.RoamingUserConfigFilename = path;

			_exeConfig = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.PerUserRoaming);
			_prefConfigSection = _exeConfig.GetSection(SettingsConfigSectionName) as SettingsSection;
			if (_prefConfigSection == null)
			{
				_prefConfigSection = new SettingsSection();
				_prefConfigSection.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser;
				_exeConfig.Sections.Add(SettingsConfigSectionName, _prefConfigSection);
			}

			this.OnPropertyChanged("Current");
		}