コード例 #1
0
        protected virtual void InternalSetValue <T>(T value, [NotNull] string key)
        {
            Contract.Requires(key != null);
            try
            {
                _configuration.SetValue(key, ConvertToString(value));

                using (var writer = new StreamWriter(File.Create(_filePath)))
                {
                    _configuration.Save(writer);
                }
            }
            catch (Exception ex)
            {
                _tracer.TraceError("Fatal error writing configuration file: " + _filePath + " - " + ex.Message);
            }
        }
コード例 #2
0
        protected virtual void InternalSetValue <T>(T value, string key)
        {
            Contract.Requires(!string.IsNullOrEmpty(key));

            try
            {
                _configuration.SetValue(key, ConvertToString <T>(value));

                using (var writer = new StreamWriter(File.Create(_filePath)))
                {
                    _configuration.Save(writer);
                }

                OnPropertyChanged(key);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fatal error writing configuration file: " + _filePath + " - " + ex.Message);
            }
        }