/// <summary> /// Concludes this editing session by combining all data files, finishing off with an /// instance of <see cref="EndSessionEvent"/>. /// </summary> internal void EndSession() { // Pick up the files that relate to the session string endFolder = Path.GetDirectoryName(m_FileName); uint[] fileNumbers = GetFileNumbers(endFolder, m_Data.EditSequence); // Create an end session event EndSessionEvent endEvent = new EndSessionEvent(m_Project.AllocateId()); string endFile = Path.Combine(endFolder, ProjectDatabase.GetDataFileName(endEvent.EditSequence)); using (StreamWriter sw = File.CreateText(endFile)) { foreach (uint fileNum in fileNumbers) { string fileName = Path.Combine(endFolder, ProjectDatabase.GetDataFileName(fileNum)); string s = File.ReadAllText(fileName); sw.Write(s); } // And finish off with the end event string endText = EditSerializer.GetSerializedString <Change>(DataField.Edit, endEvent); sw.Write(endText); } // Get rid of the files that we've just combined foreach (uint fileNum in fileNumbers) { string fileName = Path.Combine(endFolder, ProjectDatabase.GetDataFileName(fileNum)); File.Delete(fileName); } }
/// <summary> /// Concludes this editing session by combining all data files, finishing off with an /// instance of <see cref="EndSessionEvent"/>. /// </summary> internal void EndSession() { // Pick up the files that relate to the session string endFolder = Path.GetDirectoryName(m_FileName); uint[] fileNumbers = GetFileNumbers(endFolder, m_Data.EditSequence); // Create an end session event EndSessionEvent endEvent = new EndSessionEvent(m_Project.AllocateId()); string endFile = Path.Combine(endFolder, ProjectDatabase.GetDataFileName(endEvent.EditSequence)); using (StreamWriter sw = File.CreateText(endFile)) { foreach (uint fileNum in fileNumbers) { string fileName = Path.Combine(endFolder, ProjectDatabase.GetDataFileName(fileNum)); string s = File.ReadAllText(fileName); sw.Write(s); } // And finish off with the end event string endText = EditSerializer.GetSerializedString<Change>(DataField.Edit, endEvent); sw.Write(endText); } // Get rid of the files that we've just combined foreach (uint fileNum in fileNumbers) { string fileName = Path.Combine(endFolder, ProjectDatabase.GetDataFileName(fileNum)); File.Delete(fileName); } }