/// <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) { VRLog.Warn(e); } } } }
/// <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); } PostProcess(path); Path = path; } _OldSettings = this.MemberwiseClone() as VRSettings; }
public VRSettings() { PropertyChanged += Distribute; _OldSettings = this.MemberwiseClone() as VRSettings; }