/// <summary> /// Creates a new <see cref="TouchstoneWriter"/> using the specified <see cref="TextWriter"/> with default <see cref="TouchstoneWriterSettings"/>. /// </summary> /// <param name="writer">The <see cref="TextWriter"/> to which you want to write. The Touchstone data will be appended to this <see cref="TextWriter"/>.</param> /// <param name="settings">The <see cref="TouchstoneWriterSettings"/> used to configure the <see cref="TouchstoneWriter"/> instance. /// If <paramref name="settings"/> is null the default settings will be used.</param> /// <returns>A new <see cref="TouchstoneWriter"/> object.</returns> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> value is null.</exception> public static TouchstoneWriter Create(TextWriter writer, TouchstoneWriterSettings settings) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } return(new TouchstoneWriter(writer, settings)); }
/// <summary> /// Creates a new <see cref="TouchstoneWriter"/> using the specified file path with the specified settings. /// </summary> /// <param name="filePath">The file to which you want to write. The <see cref="TouchstoneWriter"/> creates a file at the specified path /// or overwrites the existing file.</param> /// <param name="settings">The <see cref="TouchstoneWriterSettings"/> used to configure the <see cref="TouchstoneWriter"/> instance. /// If <paramref name="settings"/> is null the default settings will be used.</param> /// <returns>A new <see cref="TouchstoneWriter"/> object.</returns> public static TouchstoneWriter Create(string filePath, TouchstoneWriterSettings settings) { if (string.IsNullOrEmpty(filePath)) { throw new ArgumentNullException(nameof(filePath)); } StreamWriter writer = new StreamWriter(filePath); return(new TouchstoneWriter(writer, settings)); }
/// <summary> /// Creates a new <see cref="TouchstoneWriter"/> using the specified <see cref="StringBuilder"/> with default <see cref="TouchstoneWriterSettings"/>. /// </summary> /// <param name="sb">The <see cref="StringBuilder"/> to which you want to write. The Touchstone data will be appended to this <see cref="StringBuilder"/>.</param> /// <param name="settings">The <see cref="TouchstoneWriterSettings"/> used to configure the <see cref="TouchstoneWriter"/> instance. /// If <paramref name="settings"/> is null the default settings will be used.</param> /// <returns>A new <see cref="TouchstoneWriter"/> object.</returns> /// <exception cref="ArgumentNullException">The <paramref name="sb"/> value is null.</exception> public static TouchstoneWriter Create(StringBuilder sb, TouchstoneWriterSettings settings) { if (sb == null) { throw new ArgumentNullException(nameof(sb)); } StringWriter writer = new StringWriter(sb); return(new TouchstoneWriter(writer, settings)); }
private TouchstoneWriter(TextWriter writer, TouchstoneWriterSettings settings) { this.settings = settings ?? new TouchstoneWriterSettings(); this.Writer = writer ?? throw new ArgumentNullException(nameof(writer)); }