Пример #1
0
        /// <summary>
        /// Saves the settings to a given path.
        /// </summary>
        /// <param name="path"></param>
        public virtual void Save(string path)
        {
            if (path != null)
            {
                var serializer = new XmlSerializer(GetType());
                using (var stream = File.OpenWrite(path))
                {
                    stream.SetLength(0);
                    serializer.Serialize(stream, this);
                }

                Path = path;
            }

            _OldSettings = this.MemberwiseClone() as VRSettings;
        }
Пример #2
0
 /// <summary>
 /// Clone settings from another instance.
 /// </summary>
 /// <param name="settings"></param>
 public void CopyFrom(VRSettings settings)
 {
     foreach (var key in _Listeners.Keys)
     {
         var prop = settings.GetType().GetProperty(key, BindingFlags.Instance | BindingFlags.Public);
         if (prop != null)
         {
             try
             {
                 prop.SetValue(this, prop.GetValue(settings, null), null);
             }
             catch (Exception e)
             {
                 Logger.Warn(e);
             }
         }
     }
 }
Пример #3
0
        public VRSettings()
        {
            PropertyChanged += Distribute;

            _OldSettings = this.MemberwiseClone() as VRSettings;
        }