/// <summary> /// Saves content as sentence-by-sentence files /// </summary> /// <param name="outputFilePath">The base name and extension for the text files</param> /// <returns>Array of text file names.</returns> public string[] WriteToSNTFiles(string outputFilePath) { string folder = Path.GetDirectoryName(outputFilePath); string fileName = Path.GetFileNameWithoutExtension(outputFilePath); string extension = string.Empty; if (Path.HasExtension(outputFilePath)) { extension = Path.GetExtension(outputFilePath); } string[] outputFiles = null; try { this.writers = new SntWriterContainer(Path.Combine(folder, fileName), extension); using (TmxReader rdr = new TmxReader(this.streamReader)) { foreach (TmxTag tmxTag in rdr.TmxTags) { switch (tmxTag.TmxTagType) { case TmxTagType.TU: TmxDocument tmxtuDoc = TmxDocument.Create(tmxTag.Value, true); this.ProcessTuElement(tmxtuDoc); break; ////case TmxTagType.XML: ////case TmxTagType.DOCTYPE: ////case TmxTagType.TMX_OPEN: ////case TmxTagType.HEADER: ////case TmxTagType.BODY_OPEN: default: break; } } } outputFiles = this.writers.Files; } catch { throw; } finally { if (this.writers != null) { this.writers.Dispose(); this.writers = null; } } return(outputFiles); }
/// <summary> /// Initializes a new instance of the TmxFile class. /// </summary> /// <param name="stream">Specifies a input stream.</param> public TmxFile(Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } this.streamReader = new StreamReader(stream); Debug.Assert(this.streamReader != null, "streamReader is null"); this.writers = null; this.internalCounter = 0; }
/// <summary> /// Initializes a new instance of the TmxFile class. /// </summary> /// <param name="filePath">Specifies a base file path.</param> public TmxFile(string filePath) { if (string.IsNullOrEmpty(filePath)) { throw new ArgumentNullException("filePath"); } if (!File.Exists(filePath)) { throw new ArgumentException("File not found in the specified path"); } this.streamReader = new StreamReader(filePath); Debug.Assert(this.streamReader != null, "streamReader is null"); this.writers = null; this.internalCounter = 0; }