Converter

WithInput

Sets the data source for the conversion. Accepts a file, database, grid, string, object, or dictionary list - GPAL infers the format or you can specify it explicitly with WithInputType.

Sets the data source for the conversion. Accepts a file, database, grid, string, object, or dictionary list - GPAL infers the format or you can specify it explicitly with WithInputType.

WithInput is the starting point of every converter chain. Six overloads cover every source GPAL supports: GPALFile for disk files, IGPALDatabase for database query results, IGPALGrid<string> for in-memory grids, List<Dictionary<object,object>> for raw dictionary data, a dynamic object for class instances, and string for raw text content. GPAL auto-detects the input format from the file extension or string content in most cases - use WithInputType when the format is ambiguous.

TIP

GPAL infers format from the file extension (.json, .csv, .xml, .yaml, etc.) and from string content heuristics. Use WithInputType to override when detection would be ambiguous - for example, a string that could be JSON or YAML.

WARNING

Elsewhere in GPAL, GPALFile has an implicit conversion from string, so a plain path string can be passed directly wherever GPALFile is expected. WithInput is the exception: it has its own string overload for raw text content, and C# prefers that exact-type overload over the implicit GPALFile conversion. Passing a bare string to WithInput is treated as raw content, not a file path - use GPAL.FileFor(path) to read from a file.

Examples

GPAL Fluent: High-level fluent C# API

//Any of these WithInput overloads can be chained directly into WithInputType, WithOutputType, and any SaveTo or RenderTo call. The six overloads are interchangeable from the chain's perspective - the rest of the fluent API is identical regardless of which input source you use.

// From a file - format inferred from extension GPAL.Converter .WithInput(GPAL.FileFor("data.json")); // From a database query result GPAL.Converter .WithInput(GPAL.Database .WithConnectionString("...") .ToGPALObject()); // From an in-memory grid GPAL.Converter .WithInput(myGrid); // From a raw string - specify format explicitly GPAL.Converter .WithInput("{"name":"Alice"}") .WithInputType(DataFormat.JSON); // From a class instance GPAL.Converter .WithInput(myCustomerObject);