public void Export(IProject project, ConfigParameterString exportPath, Func <ID <LocalizedText>, string> localize) { using (var sfd = new SaveFileDialog()) { sfd.DefaultExt = "*.ssv"; sfd.AddExtension = true; sfd.CreatePrompt = false; sfd.InitialDirectory = exportPath.Value; sfd.OverwritePrompt = true; sfd.ValidateNames = true; sfd.Title = "Export to C# source file"; sfd.DefaultExt = ".ssv"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { exportPath.Value = Path.GetDirectoryName(sfd.FileName); using (var stream = new FileStream(sfd.FileName, FileMode.OpenOrCreate, FileAccess.Write)) { stream.SetLength(0); using (var sw = new StreamWriter(stream)) { ExportAsSsv ssv = new ExportAsSsv(localize); ssv.WriteTitle(sw, true); foreach (var con in project.Conversations) { ssv.WriteConversation(con, sw, true); } } } } } }
public void Export(IProject2 project, ConfigParameterString exportPath, Func <Id <LocalizedStringType>, Id <LocalizedText>, Tuple <string, DateTime> > localize, IErrorCheckerUtilities <IConversationNode> util) { if (project == null) { throw new ArgumentNullException(nameof(project)); } if (exportPath == null) { throw new ArgumentNullException(nameof(exportPath)); } using (var sfd = new SaveFileDialog()) { sfd.DefaultExt = "*.ssv"; sfd.AddExtension = true; sfd.CreatePrompt = false; sfd.InitialDirectory = exportPath.Value; sfd.OverwritePrompt = true; sfd.ValidateNames = true; sfd.Title = "Export to C# source file"; sfd.DefaultExt = ".ssv"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { exportPath.Value = Path.GetDirectoryName(sfd.FileName); FileStream stream = null; try { stream = new FileStream(sfd.FileName, FileMode.OpenOrCreate, FileAccess.Write); stream.SetLength(0); using (var sw = new StreamWriter(stream)) { stream = null; ExportAsSsv ssv = new ExportAsSsv((type, textId) => localize(type, textId).Item1); CsvData.WriteTitle(";", sw, true); foreach (var con in project.ConversationFilesCollection) { ssv.WriteConversation(con, sw, true, util); } } } finally { if (stream != null) { stream.Dispose(); } } } } }