Skip to content

Commit be1ede0

Browse files
committed
Add structured data transformation to CsvPlugin
This update introduces functionality to transform the `result` into a structured data format by converting each item into an `IDictionary<string, object?>`. The new structured data is stored in a variable called `structuredData` and is included in the `PluginContext` alongside the existing `Content` property. #11
1 parent efe8ccb commit be1ede0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/CsvPlugin.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,17 @@ public Task Initialize(IPluginLogger logger)
112112
var result = handler.Handle(records, inputParameter);
113113
var csvString = await ToCsvStringAsync(result, inputParameter);
114114

115+
var structuredData = result
116+
.Select(expando => ((IDictionary<string, object?>)expando)
117+
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as object))
118+
.ToList();
119+
115120
string filename = $"{_guidProvider.NewGuid()}.csv";
116121
return new PluginContext(filename, "Data")
117122
{
118123
Format = "Csv",
119-
Content = csvString
124+
Content = csvString,
125+
StructuredData = structuredData
120126
};
121127
}
122128

0 commit comments

Comments
 (0)