/// <summary> /// Get an object that represents the current states and /// can be persisted (to standard XML serialization). /// </summary> /// <returns></returns> public ProfilePersistable GetObjectForPersistence() { var ret = new ProfilePersistable(); ret.MRU = this.MRU.GetObjectForPersistence(); ret.MainWindowPosSz = this.MainWindowPosSz; ret.LastActiveSolution = this.LastActiveSolution; ret.LastActiveSourceFile = this.LastActiveSolution; ret.LastActiveSourceFile = this.LastActiveSolution; ret.LastActiveTargetFile = this.LastActiveTargetFile; return(ret); }
/// <summary> /// Set current object states from an object that represents /// the persisted values (from standard XML serialization). /// </summary> /// <returns></returns> public void SetObjectFromPersistence(ProfilePersistable persist) { if (persist == null) { return; } this.MRU.SetObjectFromPersistence(persist.MRU); this.MainWindowPosSz = persist.MainWindowPosSz; this.LastActiveSolution = persist.LastActiveSolution; this.LastActiveSolution = persist.LastActiveSolution; this.LastActiveSolution = persist.LastActiveSolution; this.LastActiveTargetFile = persist.LastActiveTargetFile; }
/// <summary> /// Save program options into persistence. /// See <seealso cref="LoadOptions"/> to load program options on program start. /// </summary> /// <param name="sessionDataFileName"></param> /// <param name="model"></param> /// <returns></returns> public bool SaveSessionData(string sessionDataFileName, IProfile model) { var persistable = model.GetObjectForPersistence(); return(ProfilePersistable.SaveObjectToPersistence(sessionDataFileName, persistable)); }
/// <summary> /// Save program options into persistence. /// See <seealso cref="SaveOptions"/> to save program options on program end. /// </summary> /// <param name="sessionDataFileName"></param> /// <returns></returns> public void LoadSessionData(string sessionDataFileName) { // Just get the defaults if serilization wasn't working here... SessionData = new Profile(); SessionData.SetObjectFromPersistence(ProfilePersistable.GetObjectFromPersistence(sessionDataFileName)); }