GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
GenerallyPositive.GPALConverter Class Reference
Inheritance diagram for GenerallyPositive.GPALConverter:
GenerallyPositive.IGPALConverter GenerallyPositive.IAllowConverterInput GenerallyPositive.IAllowConverterSettings GenerallyPositive.IAllowConverterActions GenerallyPositive.IAllowToGPALObject< TResult > GenerallyPositive.IAllowConverterSettingsAndActions GenerallyPositive.IAllowConverterInputAndActions GenerallyPositive.IAllowToGPALObject< TResult > GenerallyPositive.IAllowToGPALObject< TResult > GenerallyPositive.IAllowConverterActions GenerallyPositive.IAllowConverterSettings GenerallyPositive.IAllowConverterActions GenerallyPositive.IAllowConverterInput GenerallyPositive.IAllowToGPALObject< TResult > GenerallyPositive.IAllowToGPALObject< TResult >

Classes

class  DataFormatDetector

Public Member Functions

IGPALConverter ToGPALObject ()
 Returns this converter cast to IGPALConverter to begin a fluent conversion chain.
IAllowConverterSettingsAndActions WithInput (List< Dictionary< object, dynamic > > inputDictionary)
 Sets the input to a list of dictionaries (one per input "document"), clearing any previously configured input/output settings.
IAllowConverterSettingsAndActions WithInput (IGPALDatabase inputDatabase)
 Sets the input to the contents of a GPAL database, clearing any previously configured input/output settings.
IAllowConverterInputAndActions SaveTo (IGPALDatabase outputDatabase)
 Converts the configured input to database format and writes the resulting rows into the given database.
IAllowConverterSettingsAndActions WithInput (IGPALGrid< string > inputGrid)
 Sets the input to a GPAL grid of strings (GRID format, comma input delimiter), clearing any previously configured input/output settings.
IAllowConverterInputAndActions SaveTo (ref IGPALGrid< string > outputGrid)
 Converts the configured input to GRID format and writes the resulting rows/columns into the given grid.
IAllowConverterSettingsAndActions WithInput (string inputData)
 Sets the input to a raw string of data, clearing any previously configured input/output settings.
If an input delimiter has not been set, the data format is auto-detected from the content (JSON/XML/YAML/CSV/etc.).
IAllowConverterInputAndActions SaveTo (string outputData)
 Converts the configured input to a string in the configured (or detected) output format.
IAllowConverterSettingsAndActions WithInput (GPALFile inputFile)
 Sets the input to one or more files, clearing any previously configured input/output settings.
The data format of each matching file is determined from its file extension.
IAllowConverterInputAndActions AppendTo (GPALFile outputFile)
 Converts the configured input and appends the resulting data to the given output file (instead of overwriting it).
IAllowConverterInputAndActions SaveTo (GPALFile outputFile)
 Converts the configured input and writes (overwrites) the resulting data to the given output file.
IAllowConverterSettingsAndActions WithInput (dynamic inputClass)
 Sets the input to an arbitrary class instance (or collection), clearing any previously configured input/output settings.
The instance is reflected/walked into a dictionary representation (CLASS format) that can then be converted to any output format.
IAllowConverterInputAndActions SaveTo< T > (ref T outputClass)
IAllowConverterSettingsAndActions WithInputType (DataFormat inDataFormat)
 Explicitly overrides the detected/assumed input data format.
IAllowConverterSettingsAndActions WithOutputType (DataFormat outDataFormat)
 Explicitly sets the output data format to use when converting.
IAllowConverterSettingsAndActions WithFirstLineHasColumnNames (bool firstLineHeaders=true)
 Specifies whether the first line/row of delimited input contains column header names.
IAllowConverterSettingsAndActions WithIgnoreFirstLineColumnNames (bool ignoreFirstLine=true)
 Specifies whether the first line/row of delimited input should be ignored (skipped) rather than treated as data or column names.
IAllowConverterSettingsAndActions WithColumnsEnclosedInQuotes (bool fieldsEnclosedInQuotes=true)
 Specifies whether delimited fields should be wrapped in quotes when writing output.
IAllowConverterSettingsAndActions WithColumnNames (List< string > columnNames)
 Supplies the column names for this conversion. Caller-supplied names override the input source's own column names (a file's column list, a database's columns) positionally; any columns the caller does not supply are backfilled from the source. The names persist until the next WithInput. The source (e.g. the GPALFile) is never modified.
IAllowConverterSettingsAndActions WithColumnName (string columnName)
 Appends a single column name to the conversion's column list. Repeated calls build the list in order. See WithColumnNames(List<string>) for override/backfill semantics.
IAllowConverterInputAndActions PrettyPrintTo (out string outputData)
 Pretty-prints JSON, YAML, XML, or HTML. Other formats (CSV, TAB, PIPE, etc.) are returned as-is.
IAllowConverterInput RegisterKnownStructType (Type knownStructType)
 Registers a struct type as a "known" type for class/dictionary conversion, so the converter can correctly recognize and reconstruct instances of it (rather than treating it as a generic nested dictionary).
IAllowConverterInputAndActions RenderTo (IGPALDatabase outputDatabase)
 Renders the configured input as a visual document (e.g. PDF or image) rather than a text data format, storing the rendered output in the given database. Not yet implemented.
IAllowConverterInputAndActions RenderTo (string outputData)
 Renders the configured input as a visual document (e.g. PDF or image) rather than a text data format, storing the rendered output in the given string. Not yet implemented.
IAllowConverterInputAndActions RenderTo (GPALFile outputFile)
 Renders the configured input as a visual document (e.g. PDF or image) rather than a text data format, writing the rendered output to the given file. Not yet implemented.
IAllowConverterInputAndActions RenderToClass (out dynamic outputClass)
 Renders the configured input as a visual document (e.g. PDF or image) rather than a text data format, storing the rendered output in the given class instance. Not yet implemented.

Detailed Description

Definition at line 40 of file GPALConverter.cs.

Member Function Documentation

◆ AppendTo()

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.AppendTo ( GPALFile outputFile)

Converts the configured input and appends the resulting data to the given output file (instead of overwriting it).

Parameters
outputFileThe file to append the converted data to; its data format is determined from its file extension
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 282 of file GPALConverter.cs.

◆ PrettyPrintTo()

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.PrettyPrintTo ( out string outputData)

Pretty-prints JSON, YAML, XML, or HTML. Other formats (CSV, TAB, PIPE, etc.) are returned as-is.

Pretty prints the data based on the CURRENT Input Format (InDataFormat). Works great with your fluent chain: WithInput(...).PrettyPrintTo(...)

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 503 of file GPALConverter.cs.

◆ RegisterKnownStructType()

IAllowConverterInput GenerallyPositive.GPALConverter.RegisterKnownStructType ( Type knownStructType)

Registers a struct type as a "known" type for class/dictionary conversion, so the converter can correctly recognize and reconstruct instances of it (rather than treating it as a generic nested dictionary).

Parameters
knownStructTypeThe struct Type to register
Returns
Fluent interface to continue configuring the converter input

Implements GenerallyPositive.IAllowConverterInput.

Definition at line 1747 of file GPALConverter.cs.

◆ RenderTo() [1/3]

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.RenderTo ( GPALFile outputFile)

Renders the configured input as a visual document (e.g. PDF or image) rather than a text data format, writing the rendered output to the given file. Not yet implemented.

Parameters
outputFileThe file that would receive the rendered output
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 1781 of file GPALConverter.cs.

◆ RenderTo() [2/3]

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.RenderTo ( IGPALDatabase outputDatabase)

Renders the configured input as a visual document (e.g. PDF or image) rather than a text data format, storing the rendered output in the given database. Not yet implemented.

Parameters
outputDatabaseThe database that would receive the rendered output
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 1759 of file GPALConverter.cs.

◆ RenderTo() [3/3]

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.RenderTo ( string outputData)

Renders the configured input as a visual document (e.g. PDF or image) rather than a text data format, storing the rendered output in the given string. Not yet implemented.

Parameters
outputDataThe string that would receive the rendered output
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 1770 of file GPALConverter.cs.

◆ RenderToClass()

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.RenderToClass ( out dynamic outputClass)

Renders the configured input as a visual document (e.g. PDF or image) rather than a text data format, storing the rendered output in the given class instance. Not yet implemented.

Parameters
outputClassThe object that would receive the rendered output
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 1792 of file GPALConverter.cs.

◆ SaveTo() [1/4]

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.SaveTo ( GPALFile outputFile)

Converts the configured input and writes (overwrites) the resulting data to the given output file.

Parameters
outputFileThe file to write the converted data to; its data format is determined from its file extension
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)
.WithInput((GPALFile)GPAL.File.WithFileName("input.csv"))
.SaveTo((GPALFile)GPAL.File.WithFileName("output.json"));
GPAL File object instantied with GPAL.File Used to load tokens into a GPALGrid [rows/columns].
Definition GPALFile.cs:36
Everything starts here, all the GPAL controls and global settings using fluent syntax are here....
Definition GPAL.cs:49
static IAllowConverterInput Converter
New GPAL Convertor.
Definition GPAL.cs:560
static IAllowFileName File
Instantiates a new fluent File SETTINGS object. This data object defines settings for use by the ....
Definition GPAL.cs:508

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 301 of file GPALConverter.cs.

◆ SaveTo() [2/4]

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.SaveTo ( IGPALDatabase outputDatabase)

Converts the configured input to database format and writes the resulting rows into the given database.

Parameters
outputDatabaseThe database to write the converted rows into
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 141 of file GPALConverter.cs.

◆ SaveTo() [3/4]

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.SaveTo ( ref IGPALGrid< string > outputGrid)

Converts the configured input to GRID format and writes the resulting rows/columns into the given grid.

Parameters
outputGridThe grid to receive the converted rows; also used to determine the output element type
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 185 of file GPALConverter.cs.

◆ SaveTo() [4/4]

IAllowConverterInputAndActions GenerallyPositive.GPALConverter.SaveTo ( string outputData)

Converts the configured input to a string in the configured (or detected) output format.

Parameters
outputDataThe output data string; the converted result is stored on the converter's settings
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterActions.

Definition at line 242 of file GPALConverter.cs.

◆ SaveTo< T >()

◆ ToGPALObject()

IGPALConverter GenerallyPositive.GPALConverter.ToGPALObject ( )

Returns this converter cast to IGPALConverter to begin a fluent conversion chain.

Returns
This GPALConverter as an IGPALConverter

Implements GenerallyPositive.IAllowToGPALObject< TResult >.

Definition at line 92 of file GPALConverter.cs.

◆ WithColumnName()

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithColumnName ( string columnName)

Appends a single column name to the conversion's column list. Repeated calls build the list in order. See WithColumnNames(List<string>) for override/backfill semantics.

Parameters
columnNameThe column name to append.
Returns
Fluent interface to continue building the conversion.

Implements GenerallyPositive.IAllowConverterSettings.

Definition at line 465 of file GPALConverter.cs.

◆ WithColumnNames()

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithColumnNames ( List< string > columnNames)

Supplies the column names for this conversion. Caller-supplied names override the input source's own column names (a file's column list, a database's columns) positionally; any columns the caller does not supply are backfilled from the source. The names persist until the next WithInput. The source (e.g. the GPALFile) is never modified.

Parameters
columnNamesThe ordered column names to use for this conversion.
Returns
Fluent interface to continue building the conversion.

Implements GenerallyPositive.IAllowConverterSettings.

Definition at line 451 of file GPALConverter.cs.

◆ WithColumnsEnclosedInQuotes()

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithColumnsEnclosedInQuotes ( bool fieldsEnclosedInQuotes = true)

Specifies whether delimited fields should be wrapped in quotes when writing output.

Parameters
fieldsEnclosedInQuotesTrue to enclose each output field in quotes (default true)
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterSettings.

Definition at line 437 of file GPALConverter.cs.

◆ WithFirstLineHasColumnNames()

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithFirstLineHasColumnNames ( bool firstLineHeaders = true)

Specifies whether the first line/row of delimited input contains column header names.

Parameters
firstLineHeadersTrue if the first line/row contains column names (default true)
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterSettings.

Definition at line 416 of file GPALConverter.cs.

◆ WithIgnoreFirstLineColumnNames()

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithIgnoreFirstLineColumnNames ( bool ignoreFirstLine = true)

Specifies whether the first line/row of delimited input should be ignored (skipped) rather than treated as data or column names.

Parameters
ignoreFirstLineTrue to skip the first line/row of the input (default true)
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterSettings.

Definition at line 427 of file GPALConverter.cs.

◆ WithInput() [1/6]

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithInput ( dynamic inputClass)

Sets the input to an arbitrary class instance (or collection), clearing any previously configured input/output settings.
The instance is reflected/walked into a dictionary representation (CLASS format) that can then be converted to any output format.

Parameters
inputClassThe object, collection, or dictionary to use as the conversion input
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterInput.

Definition at line 316 of file GPALConverter.cs.

◆ WithInput() [2/6]

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithInput ( GPALFile inputFile)

Sets the input to one or more files, clearing any previously configured input/output settings.
The data format of each matching file is determined from its file extension.

Parameters
inputFileThe GPALFile (which may expand to multiple matching files) to use as the conversion input
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterInput.

Definition at line 262 of file GPALConverter.cs.

◆ WithInput() [3/6]

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithInput ( IGPALDatabase inputDatabase)

Sets the input to the contents of a GPAL database, clearing any previously configured input/output settings.

Parameters
inputDatabaseThe database whose tokenized rows are used as the conversion input
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterInput.

Definition at line 121 of file GPALConverter.cs.

◆ WithInput() [4/6]

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithInput ( IGPALGrid< string > inputGrid)

Sets the input to a GPAL grid of strings (GRID format, comma input delimiter), clearing any previously configured input/output settings.

Parameters
inputGridThe grid of string values to use as the conversion input
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterInput.

Definition at line 159 of file GPALConverter.cs.

◆ WithInput() [5/6]

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithInput ( List< Dictionary< object, dynamic > > inputDictionary)

Sets the input to a list of dictionaries (one per input "document"), clearing any previously configured input/output settings.

Parameters
inputDictionaryList of dictionaries to use as the conversion input
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Definition at line 101 of file GPALConverter.cs.

◆ WithInput() [6/6]

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithInput ( string inputData)

Sets the input to a raw string of data, clearing any previously configured input/output settings.
If an input delimiter has not been set, the data format is auto-detected from the content (JSON/XML/YAML/CSV/etc.).

Parameters
inputDataThe raw input data (e.g. CSV, JSON, XML, YAML, delimited text)
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)
string json = "{\"name\":\"Alice\",\"age\":30}";
GPAL.Converter.ToGPALObject()
.WithInput(json)
.WithOutputType(DataFormat.YAML)
.SaveTo(out string yaml);

Implements GenerallyPositive.IAllowConverterInput.

Definition at line 219 of file GPALConverter.cs.

◆ WithInputType()

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithInputType ( DataFormat inDataFormat)

Explicitly overrides the detected/assumed input data format.

Parameters
inDataFormatThe data format to treat the configured input as
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterSettings.

Definition at line 387 of file GPALConverter.cs.

◆ WithOutputType()

IAllowConverterSettingsAndActions GenerallyPositive.GPALConverter.WithOutputType ( DataFormat outDataFormat)

Explicitly sets the output data format to use when converting.

Parameters
outDataFormatThe data format to convert the input to
Returns
Fluent interface to continue building the conversion (e.g. call SaveTo/AppendTo/RenderTo, or AndThen)

Implements GenerallyPositive.IAllowConverterSettings.

Definition at line 406 of file GPALConverter.cs.


The documentation for this class was generated from the following file: