| | | 1 | | using System.Globalization; |
| | | 2 | | using ValidateLib.ResultCreators.Csv; |
| | | 3 | | using ValidateLib.ResultCreators.Rdf; |
| | | 4 | | |
| | | 5 | | namespace ValidateLib.ResultCreators |
| | | 6 | | { |
| | | 7 | | /// <summary> |
| | | 8 | | /// Creates instances of <see cref="IResultWriter"/> based on the input from user. |
| | | 9 | | /// </summary> |
| | | 10 | | public class ResultWriterFactory |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Creates correct instance of <see cref="IResultWriter"/> based on the |
| | | 14 | | /// <paramref name="fileFormat"/> |
| | | 15 | | /// </summary> |
| | | 16 | | /// <param name="fileFormat"> Desired file format in which the result file should be.</param> |
| | | 17 | | /// <param name="culture"> Culture in which the warnings and errors should be.</param> |
| | | 18 | | /// <returns> Correct <see cref="IResultWriter"/> instance .</returns> |
| | | 19 | | public static IResultWriter CreateResultWriter(ResultFileFormat fileFormat, CultureInfo? culture = null) |
| | | 20 | | { |
| | 1 | 21 | | if (culture is null) |
| | | 22 | | { |
| | 1 | 23 | | culture = CultureInfo.InvariantCulture; |
| | | 24 | | } |
| | | 25 | | switch (fileFormat) |
| | | 26 | | { |
| | | 27 | | case ResultFileFormat.CSV: |
| | 1 | 28 | | return new CsvResultWriter(culture); |
| | | 29 | | case ResultFileFormat.RDF: |
| | 1 | 30 | | return new RdfResultWriter(culture); |
| | | 31 | | default: |
| | 0 | 32 | | return new CsvResultWriter(culture); |
| | | 33 | | } |
| | | 34 | | } |
| | | 35 | | } |
| | | 36 | | } |