/// <summary> /// Renders the object as a properly formatted Touchstone file based on the configured Touchstone options. /// </summary> /// <returns>A string representation of a Touchstone file.</returns> public override string ToString() { StringBuilder sb = new StringBuilder(); using TouchstoneWriter writer = TouchstoneWriter.Create(sb); writer.Options = Options; writer.Keywords = Keywords; foreach (var data in NetworkParameters) { writer.WriteData(data); } return(sb.ToString()); }
/// <summary>Writes the Touchstone file object to the specified file with the specified writer settings.</summary> /// <param name="filePath">The *.sNp file to be created or overwritten.</param> /// <param name="settings">Additional settings regarding how the network data in the file should be written.</param> /// <remarks>Use the <see cref="TouchstoneWriter"/> class for more control over the file writing process.</remarks> public void Write(string filePath, TouchstoneWriterSettings settings) { if (filePath == null) { throw new ArgumentNullException(nameof(filePath)); } using (TouchstoneWriter writer = TouchstoneWriter.Create(filePath, settings)) { writer.Options = Options; writer.Keywords = Keywords; foreach (var pair in NetworkParameters) { writer.WriteData(pair); } writer.Flush(); }; }